简体   繁体   中英

what is the range of DateTime.TryParseExact or Convert.ToDateTime() having date format dd/MM/yy

I want to know the range of DateTime.TryParseExact method or Convert.ToDateTime() having dd/MM/yy as input format. like

DateTime.TryParseExact("01/07/05","dd/MM/yy",  new CultureInfo("en-US"),DateTimeStyles.None, out dateValue)

or

DateTime Time=Convert.ToDateTime("01/07/05");

If i will give 01/07/35, it will not know whether I am talking about 1835,1935,2035. So defiantly it has some range. Any body know about its rang with some reference ?

Thanks

If you're asking how a two digit year is interpreted, it depends on the culture's TwoDigitYearMax property

Which depends on the computer's settings. To see what the setting is go to:

  1. Control Panel -> Regional and Language Options
  2. Customize (XP) or Additional Settings (Win7)
  3. Date Tab. There is a setting there on how two digit years are interpreted. On my computer it's interpreted as between 1930 and 2029.

Year values from 00 to 29 will give you the years 2000 to 2029, values from 30 to 99 will give you the hears 1930 to 1999.

The value new CultureInfo("en-US").DateTimeFormat.Calendar.TwoDigitYearMax contains 2029 , which determines the breaking point.

DateTime range is between DateTime.MinValue ( 00:00:00.0000000, January 1, 0001 ) to DateTime.MaxValue ( 23:59:59.9999999, December 31, 9999 ).

http://msdn.microsoft.com/en-us/library/system.datetime.minvalue.aspx

http://msdn.microsoft.com/en-us/library/system.datetime.maxvalue.aspx

Default century is controlled by http://msdn.microsoft.com/en-us/library/system.globalization.calendar.twodigityearmax.aspx

认为它将假设当前[编辑]世纪(而不是千年)(在系统时钟中设置)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM