[Delphi] Use strtodatetime in different operating systems

Source: Internet
Author: User
STR: = '2017-4-13 06:22:22 ';

Strtodatetime (STR );

Symptom: no error is reported in WINXP or win2003.

However, in Windows 7 and Windows Server 2008, the error 'xxx' is not a valid date and time is reported.

Later, we found that the default short date styles for different operating systems were different.

In WINXP and win2003, the default short date style is XXXX-XX-xx.

In Windows 7 and Windows Server 2008, the default short date style is xxxx/X/xx.

You can view the short date style through the control panel ----> region settings -------> date ----->



 

You can modify the registry for better program compatibility.

 

In HKEY_CURRENT_USER \ Control Panel \ International, the value of sdate is forcibly set '/',

 

This method is not very good. The best thing is that the program makes judgment and adapts to the system, instead of changing the system settings to adapt to the program.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.