1. Long Date/Short Date/Long Time/Short Time,可以在系统的“Region and Language”中找到相应设置;
2. ISO Format/Local Format/UTC Format (注:系统格式为德国时间格式)
string longDateStr = DateTime.Now.ToLongDateString(); string shortDateStr = DateTime.Now.ToShortDateString(); string longTimeStr = DateTime.Now.ToLongTimeString(); string shortTimeStr = DateTime.Now.ToShortTimeString(); string localTimeStr = DateTime.Now.ToLocalTime().ToString(); string utcDateStr = DateTime.UtcNow.ToString(); string isoTimeStr = DateTime.Now.ToString(@"yyyy-MM-ddTHH:mm:ss"); Console.WriteLine("Long Date String: " + longDateStr); Console.WriteLine("Short Date String: " + shortDateStr); Console.WriteLine("Long Time String: " + longTimeStr); Console.WriteLine("Long Time String: " + shortTimeStr); Console.WriteLine("Local Time String: "+localTimeStr); Console.WriteLine("UCT Now String: " + utcDateStr); Console.WriteLine("ISO Time String: " + isoTimeStr); Console.Read();
得到的结果:
3. SharePoint中的日期进行查询之前,需要先更改为 ISO8601格式的标准日期格式:
//JavaScript Code string startDateFx = startDate.ToString("yyyy-MM-ddTHH:mm:ssZ"); string endDatFx = endDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
在C#中可以使用 SPUtility.CreateISO8601DateTimeFromSystemDateTime() 来实现;
时间值最后的字母 Z 标识着这个时间属于UTC时间;
4.