惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Vercel News
Vercel News
L
LangChain Blog
B
Blog RSS Feed
Y
Y Combinator Blog
IT之家
IT之家
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
V
V2EX
博客园 - 三生石上(FineUI控件)
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
阮一峰的网络日志
阮一峰的网络日志
有赞技术团队
有赞技术团队
D
Docker
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
月光博客
月光博客

博客园 - 阿社

!!如何看到真实的服务器 错误提示 !访问网站出现Directory Listing Denied 是什么原因? !后台登录总 提示验证码错误!! !设置IIS后 访问提示 页面不存在 HTTP 500错误 Windows2003网络服务器安全攻略! Win2003 ISS下Asp配置技巧 http 500内部服务器错误 !商城登录后不能自动在社区登录! ASP.NET中TreeView控件使用小结 使用IE WebControls中的TabStrip控件和MultiPage控件实现选项卡式风格页面 [程序员必看]请不要做浮躁的人 未能在设计视图中打开,在中以不同方式将值括起来 我应该用DataReader类还是DataSet类呢?” DataGrid、DataList和Repeater控件 ListBox控件使用 DropDownList控件使用 C#笔记 ASP常用三十三种代码 ASP.net数据绑定概述和语法 编程控制控件Style属性
C#常用函数和方法集汇总-日期函数
阿社 · 2006-09-02 · via 博客园 - 阿社

C#常用函数和方法集汇总

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 取当前年月日,格式为:2003-9-23
string strYMD=currentTime.ToString("d");
  1.13 取当前时分,格式为:14:24
string strT=currentTime.ToString("t");