最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

日期时间自定义格式 / Date time custom formats

网络文摘 William 279浏览 0评论

Sometime we have to deal with custom date formats, scenarios like you want to append any custom date format in the file name. In such case we can use DateTime.ParseExact() method through .NET Interop:

Ax example can be :

System.Globalization.CultureInfo culture
    = System.Globalization.CultureInfo::get_InvariantCulture();

utcDateTime dt = System.DateTime::ParseExact(
                            '10/17/2014 0:00',
                            'MM/dd/yyyy H:mm',
                            culture);
Parameters details about DateTime.ParseExact():

s String

A string that contains a date and time to convert. format String A format specifier that defines the required format of s. For more information, see the Remarks section. provider IFormatProvider An object that supplies culture-specific format information about s. Returns DateTime An object that is equivalent to the date and time contained in s, as specified by format and provider.
发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址