简体   繁体   English

具有日期格式dd / MM / yy的DateTime.TryParseExact或Convert.ToDateTime()的范围是多少

[英]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. 我想知道具有dd / MM / yy作为输入格式的DateTime.TryParseExact方法或Convert.ToDateTime()的范围。 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. 如果我将在01/07/35给出,它将不知道我是否在谈论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 如果你问的是如何解释两位数的年份,它取决于文化的TwoDigitYearMax属性

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) 自定义(XP)或其他设置(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. 在我的电脑上,它被解释为1930年至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. 从00到29的年份值将为您提供2000年至2029年的年份,从30到99的值将为您提供1930年至1999年的听力。

The value new CultureInfo("en-US").DateTimeFormat.Calendar.TwoDigitYearMax contains 2029 , which determines the breaking point. 值为new CultureInfo("en-US").DateTimeFormat.Calendar.TwoDigitYearMax包含2029 ,它确定断点。

DateTime range is between DateTime.MinValue ( 00:00:00.0000000, January 1, 0001 ) to DateTime.MaxValue ( 23:59:59.9999999, December 31, 9999 ). DateTime范围介于DateTime.MinValue00:00:00.0000000,0001年1月1日 )至DateTime.MaxValue23:59:59.9999999,12月31日,9999 )之间。

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

http://msdn.microsoft.com/en-us/library/system.datetime.maxvalue.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 默认世纪由http://msdn.microsoft.com/en-us/library/system.globalization.calendar.twodigityearmax.aspx控制

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DateTime.TryParseExact格式MM / dd / yyyy - DateTime.TryParseExact format MM/dd/yyyy 将.ToDateTime('Datestring')转换为日期所需的dd-MM-yyyy格式 - Convert.ToDateTime('Datestring') to required dd-MM-yyyy format of date C#Convert.ToDateTIme函数是否将日期读为“dd / mm / yyyy”或“mm / dd / yyyy”? - Does the C# Convert.ToDateTIme function read date as “dd/mm/yyyy” or “mm/dd/yyyy”? DateTime.TryParseExact对于MM / dd / yyyy hh:mm返回false - DateTime.TryParseExact returns false for MM/dd/yyyy hh:mm 如何告诉convert.todatetime输入格式为dd-mm-yyyy - how to tell convert.todatetime that the input is in format dd-mm-yyyy Convert.ToDateTime('Datestring') 到所需的 dd-MMM-yyyy 日期格式 - Convert.ToDateTime('Datestring') to required dd-MMM-yyyy format of date Convert.ToDateTime或DateTime.ParseExact(字符串,格式,null) - Convert.ToDateTime OR DateTime.ParseExact(string, Format, null) 如何在C#中执行Convert.ToDateTime或解析日期,但在C#2.0中仅获得dd / mm / yyyy? - How to do Convert.ToDateTime or parse date in C# but only get dd/mm/yyyy in C# 2.0? 第一次运行 Convert.ToDateTime() 时如何将 DateTime 显示为 Date - How to display DateTime as Date when Convert.ToDateTime() was run first 使用DateTime.TryParseExact格式化日期字符串并忽略时间 - Use DateTime.TryParseExact to format date string and ignore time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM