当前位置:编程学习 > C#/ASP.NET >>

如何把时间转换成9999-12-31T08:00:00+08:00这样的实践格式?

这是UTC时间,要把它转换成9999-12-31T08:00:00+08:00格式,放入XML中 
谢谢! --------------------编程问答-------------------- DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss:zzzz") --------------------编程问答--------------------
using System;

class Program
{
  static void Main()
  {
    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));
    Console.WriteLine(DateTime.Now.ToString("o"));
  }
}
/* 程序输出:
2008-06-06T19:31:00+08:00
2008-06-06T19:31:00.6566319+08:00
*/
--------------------编程问答--------------------
using System;

class Program
{
  static void Main()
  {
    Console.WriteLine(DateTime.Now.ToString("s"));
    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz"));
    Console.WriteLine(DateTime.Now.ToString("o"));
  }
}
/* 程序输出:
2008-06-06T19:33:41
2008-06-06T19:33:41+08:00
2008-06-06T19:33:41.5531766+08:00
*/
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,