返回列表 发帖

[ASP] Asp.Net日期时间格式设置

1、datetime 数字型
system.datetime currenttime=new system.datetime();

1.1 取当前年月日时分秒
currenttime=system.datetime.now;
1.2 取当前年
int 年=currenttime.year;
1.3 取当前月
int 月=currenttime.month;
1.4 取当前日
int 日=currenttime.day;
1.5 取当前时
int 时=currenttime.hour;
1.6 取当前分
int 分=currenttime.minute;
1.7 取当前秒
int 秒=currenttime.second;
1.8 取当前毫秒
int 毫秒=currenttime.millisecond;
(变量可用中文)

1.9 取中文日期显示——年月日时分
string stry=currenttime.tostring("f"); //不显示秒

1.10 取中文日期显示_年月
string strym=currenttime.tostring("y");

1.11 取中文日期显示_月日
string strmd=currenttime.tostring("m");

1.12 取中文年月日
string strymd=currenttime.tostring("d");

1.13 取当前时分,格式为:14:24
string strt=currenttime.tostring("t");

1.14 取当前时间,格式为:2003-09-23t14:46:48
string strt=currenttime.tostring("s");

1.15 取当前时间,格式为:2003-09-23 14:48:30z
string strt=currenttime.tostring("u");

1.16 取当前时间,格式为:2003-09-23 14:48
string strt=currenttime.tostring("g");

1.17 取当前时间,格式为:tue, 23 sep 2003 14:52:40 gmt
string strt=currenttime.tostring("r");

1.18获得当前时间 n 天后的日期时间
datetime newday = datetime.now.adddays(100);

好像很难的说……觉得ASP好学点……

TOP

TOP

好!!!!!!!

TOP

终于看完了~~~

TOP

看过,的确不错。谢谢楼主

TOP

终于看完了~~~

TOP

呵呵,支持一下!

TOP

顶!!!!!!!

TOP

返回列表

Powered by Discuz! 7.2   论坛QQ群:逐梦论坛群

© 2001-2021 Comsenz Inc. 鲁公网安备 37120302000001号