您的位置:首页 > 编程语言 > ASP

asp.net DateTime 时间函数

2008-08-01 10:01 609 查看
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;

(变量可用中文)

2.

dateObj = new Date();

dateObj.getYear();

dateObj.getMonth();

dateObj.getDate();

dateObj.getHour();

dateObj.getMinutes();

dateObj.getSeconds();

dateObj.getMilliseconds();

3.

DateTime now = new DateTime();

now = System.DateTime.Now;

String dateStr = now.ToString("yyyy年MM月dd日 HH:mm:ss");

出来的格式是如“2005年09月01日 12:00:00”

4、Int32.Parse(变量) Int32.Parse("常量")

字符型转换 转为32位数字型
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: