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位数字型
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位数字型
相关文章推荐
- ASP.NET时间函数及其格式转换
- (C#)Asp.net日期、时间函数大全
- asp.net 中datetime获取当前系统时间的大全
- asp.net 时间戳与datetime 转换
- ASP.NET中处理datetime的一些通用函数
- ASP.net中DateTime获取当前系统时间的大全-转载晴朗_Raymond的博客
- 向Asp.net Ajax 传入DateTime类型后时间变化的问题
- (C#)Asp.net日期、时间函数大全
- ASP.Net 获取服务器的当前日期时间的综合处理函数!
- 详细介绍asp.net获取日期时间的各种格式的函数
- ASP.NET时间函数及其格式转换
- DateTime.ToString()方法的参数谈ASP.NET中时间格式的转换
- asp.net时间处理函数
- ASP.NET MVC处理JsonResult返回时间DateTime问题
- 向Asp.net Ajax 传入DateTime类型后时间会变为零时区的时间
- Asp.net DateTime类型改变时间
- ahjesus在asp.net中还可以通过设置HttpCookie对象的过期时间为DateTime.MinValue来指定此Cookies为跟随浏览器生效
- ASP.net中DateTime获取当前系统时间的大全
- ASP.net中DateTime获取当前系统时间的大全
- Asp 时间格式化函数 FormatDateTime