如何转换smalldatime GMT格式?

时间:2011-01-17 16:16:33

标签: c# asp.net

pubdate是smalldatetime。

new XElement("pubDate", FormatPubDate(Convert.ToDateTime(rDetail.PubDate)))
    ///******************
private static string FormatPubDate(DateTime pubDate)
{
    //string Format = "yyyy-MM-dd HH:mm:ss";
    string _tmpdate = pubDate.ToUniversalTime().ToString("R");
    return pubDate.ToString(_tmpdate);
}

我的格式是ri,2011年1月14日08:34:00 G1T 但我想要这种格式 星期一,2011年1月17日10:16:12 GMT

1 个答案:

答案 0 :(得分:1)

目前还不清楚你在问什么,因为“R”格式会生成你所要求的形式。那是ToString("R")Mon, 17 Jan 2011 10:16:12 GMT

查看ToString(string)的文档,了解标准日期/时间格式字符串和示例输出的列表。

如果没有符合您需求的标准格式字符串,那么您可以构建自己的Custom Date and Time Format Strings

相关问题