首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

简单的日期格式处理有关问题

2012-01-14 
简单的日期格式处理问题?stringYearDateTime.Now.Year.ToString()stringMonthDateTime.Now.Month.ToStr

简单的日期格式处理问题?
string   Year   =   DateTime.Now.Year.ToString();
string   Month   =   DateTime.Now.Month.ToString();
string   DateMonth   =   Year   +   "- "   +   Month;
我要求的日期的年月格式统一为如:2007-02
但有现在DataMonth输出的格式为2007-2
请问如何将DateMonth格式2007-2转换为2007-02呢?
THS

[解决办法]
string DateMonth = DateTime.Now.ToString( "yyyy-MM ");
[解决办法]
string DateMonth = DateTime.Now.ToString( "yyyy-MM ");

strcpy :)
[解决办法]
string DateMonth = DateTime.Now.ToString( "yyyy-MM ");年月
string DateMonth = DateTime.Now.ToString( "yyyy-MM-dd ");年月日
string DateMonth = DateTime.Now.ToString( "yyyy-MM-dd hh:mm:ss ");年月日 時分秒

热点排行