C# 中日期格式的转换
有谁可以告诉我“1110620”是什么类型的日期格式吗?我怎样才能将其转换为“yyyy-MM-dd”格式。非常感谢任何帮助。谢谢!
is there anyone there who can tell me what type of a date format is this '1110620'? And how can I convert this to a 'yyyy-MM-dd' format. Any help is highly appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这应该有效:
或者你可以尝试(不优雅但有效)
This should work:
or you can try (not elegant but works)
上面的格式好像是-yyyMMdd。您可以编写 C# 方法来相应地转换它。请参阅 MSDN 了解更多详细信息。
The above format seems to be - yyyMMdd. You can write c# method to convert it accordingly. Refer MSDN for more details.
我的猜测是前 3 位数字是两位数年份的扩展。其中 100 对应于 2000 年。
因此,格式最初为
yyMMdd
,或者可能是(year-1900)*10000+month*100+day
,逻辑上延伸到之后的年份2000 通过前缀1
。这也保留了整数排序顺序。因此,要解析它,您可以:
使用此公式
1110620
对应于2011-06-20
但除非您解释示例的含义,否则这只是猜测。
我的第一个猜测是,这可能是自某个日期以来的几天,但这将使起源位于公元前 1000 年左右,这是不可能的。
My guess is that the first 3 digits are an extension of a two digit year. Where 100 corresponds to the year 2000.
So the format was originally
yyMMdd
and or perhaps(year-1900)*10000+month*100+day
which extends logically to years after 2000 by prefixing a1
. This also preserves integer sorting order.So to parse it you could:
With this formula
1110620
corresponds to2011-06-20
But unless you explain what your example should mean, this is just speculation.
My first guess was that it might be days since a certain date, but this would put the origin at around 1000BC, which is unlikely.