Given a DateTime object, how do I get an ISO 8601 date in string format?

后端 未结 18 2219
暖寄归人
暖寄归人 2020-11-22 02:15

Given:

DateTime.UtcNow

How do I get a string which represents the same value in an ISO 8601-compliant format?

Note that ISO 8601 de

18条回答
  •  渐次进展
    2020-11-22 02:31

    If you're developing under SharePoint 2010 or higher you can use

    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Utilities;
    ...
    string strISODate = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now)
    

提交回复
热议问题