自定义日期时间格式 [英] custom date time format

查看:175
本文介绍了自定义日期时间格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要格式化日期,如2010-04-21 11:35:22.440。 ?谁能帮助我

i need to format date like "2010-04-21 11:35:22.440". can anyone help me?

问题是我看到无论是2009-06-15T13:45:30.0900000或2008-03-09 16:05:07Z但不一个我期待的。谢谢

the problem is i am seeing either 2009-06-15T13:45:30.0900000 or 2008-03-09 16:05:07Z but not the one i am looking for. thanks.

推荐答案

使用格式YYYY-MM-DD HH:MM:SS.FFF 的日期变量的ToString

Use the format "yyyy-MM-dd hh:mm:ss.fff" with the ToString of the date variable.

例如:

Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));

这篇关于自定义日期时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆