Str:=  '2010-4-13  06:22:22';

StrToDateTime(Str);

现象:在WinXP, Win2003 都不会报错

但是在Windows7,Windows Server 2008 上,报 ‘xxx’  is not a valid  date and time  错误

后来发现不同操作系统的默认的 短日期样式 是不同的

WinXP, Win2003 默认短日期样式是 xxxx-xx-xx

Windows7, Windows Server 2008 默认短日期样式是 xxxx/x/xx

可以通过 控制面板---->区域设置------->日期----->短日期样式  查看

为了程序有更好的兼容性,可以进行注册表修改 
HKEY_CURRENT_USER/Control   Panel/International其中的sDate项将其值强制设置成'/',

这个办法不是非常好,最好的是程序做判断,适应系统,而不是更改系统设置来适应程序

http://blog.csdn.net/missmecn/article/details/5870591

Delphi使用StrToDatetime在不同操作系统出现不同的情况(控制面板的时间格式都记录在注册表里,因此也可修改注册表)的更多相关文章

  1. Delphi中StrToDateTime函数TFormatSettings参数的使用

    var    FSetting : TFormatSettings;    DateTime1: tDateTime;  begin    FSetting := TFormatSettings.Cr ...

  2. Delphi获取与设置系统时间格式,即GetLocaleInfo和SetLocaleInfo

    在Delphi中,特别是在写管理系统软件时,经常要用到 FormatDateTime 以将 TDateTime 格式的日期时间转换成字符串形式的值显示或保存起来,或者用 StrToDateTime将字 ...

  3. delphi 时间格式操作

    FormatDateTime('yyyy-mm-dd hh:nn:ss',Now) FormatDateTime('hh:mm:ss:zz',Now) if (TimeOf(now) < pub ...

  4. Delphi获得与设置系统时间格式《转》

    unit Unit1; interface uses   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Syst ...

  5. 转换GMT秒数为日期时间格式-Delphi源码

    转换GMT秒数为日期时间格式-Delphi源码.收藏最近在写PE分析工具的时候,需要转换TimeDateStamp字段值为日期时间格式,这是Delphi的源码. //把GMT时间的秒数转换成日期时间格 ...

  6. 获取硬件信息的delphi源码CPUID、操作系统、Mac物理地址、计算机名称、IP地址、用户名

    {-----------------------------------------------------------------------------作者:sushengmiyan 2013.0 ...

  7. delphi RAD Studio新版本及路线图 及官方网站 官方 版本发布时间

    delphi  RAD Studio Berlin 10.1 主要是FireMonkey 移动开发的改动,VCL确实没有多大变化. http://docwiki.embarcadero.com/RAD ...

  8. 贴一份用delphi修改注册表改网卡MAC地址的代码

    //提示:此代码需要use Registry, Common; function WriteMAC(model:integer):integer; var reg:TRegistry; begin r ...

  9. 不修改系统日期和时间格式,解决Delphi报错提示 '****-**-**'is not a valid date and time

    假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date ...

随机推荐

  1. 解决项目打包过程检出项目出现 svn:e15500错误

    svn:E15500 is already a working copy for a different url 原因:文件夹含有svn信息的隐藏文件未删除 解决办法:把该文件夹删除掉,然后重新建立同 ...

  2. 知识点1-3:MVC设计模式

    MVC代表模型-视图-控制器(Model-View-Controller),起源于20世纪70年代的Smalltalk开发社区,2003年起随着Ruby on Rails的出现才在Web上流行使用. ...

  3. GExpert 1.38 实验版含经典代码格式工具 Berlin 编译版

    安装方法:修改install.reg,然后导入.源代码地址:http://blog.dummzeuch.de/experimental-gexperts-version/ http://bbs.2cc ...

  4. Android GsonUtils工具类

    有那么一个开源jar包,叫gson 可以很方便的将java中的对象和字符串相互转化,数据传输和处理的时候,用到的可能性很大 https://github.com/google/gson http:// ...

  5. 基于visual Studio2013解决C语言竞赛题之0903文件读写

       题目

  6. 基于visual Studio2013解决C语言竞赛题之0810链表去重

     题目

  7. PS 滤镜算法原理 ——马赛克

    % method : 利用邻域的随意一点取代当前邻域全部像素点 %%%% mosaic clc; clear all; addpath('E:\PhotoShop Algortihm\Image Pr ...

  8. Get started - UIkit documentation

    Get started - UIkit documentation Get started Get familiar with the basic setup and structure of UIk ...

  9. Swing Dance!摇摆舞!小组

    Swing Dance!摇摆舞!小组 Swing Dance!摇摆舞

  10. POJ 1042 Gone Fishing (贪心)(刘汝佳黑书)

    Gone Fishing Time Limit: 2000MS   Memory Limit: 32768K Total Submissions: 30281   Accepted: 9124 Des ...