- 浏览: 769257 次
- 性别:
- 来自: 大连
文章分类
- 全部博客 (417)
- ASP.NET MVC (18)
- WEB基础 (24)
- 数据库 (69)
- iPhone (20)
- JQuery (3)
- Android (21)
- UML (8)
- C# (32)
- 移动技术 (19)
- 条码/RFID (6)
- MAC (8)
- VSS/SVN (6)
- 开卷有益 (4)
- 应用软件 (1)
- 软件工程 (1)
- java/Eclipse/tomcat (61)
- 英语学习 (2)
- 综合 (16)
- SharePoint (7)
- linux (42)
- Solaris/Unix (38)
- weblogic (12)
- c/c++ (42)
- 云 (1)
- sqlite (1)
- FTp (2)
- 项目管理 (2)
- webservice (1)
- apache (4)
- javascript (3)
- Spring/Struts/Mybatis/Hibernate (4)
- 航空业务 (1)
- 测试 (6)
- BPM (1)
最新评论
-
dashengkeji:
1a64f39292ebf4b4bed41d9d6b21ee7 ...
使用POI生成Excel文件,可以自动调整excel列宽等(转) -
zi_wu_xian:
PageOffice操作excel也可以设置表格的行高列宽,并 ...
使用POI生成Excel文件,可以自动调整excel列宽等(转) -
wanggang0321:
亲,我在pptx(office2007以上版本)转pdf的时候 ...
JODConverter]word转pdf心得分享(转) -
xiejanee:
楼主:你好!我想请问下 你在代码中用DOMDocument* ...
Xerces-C++学习之——查询修改XML文档 (转)
DateTime dt = DateTime.Now;
// Label1.Text = dt.ToString();//2005-11-5 13:21:25
// Label2.Text = dt.ToFileTime().ToString();//127756416859912816
// Label3.Text = dt.ToFileTimeUtc().ToString();//127756704859912816
// Label4.Text = dt.ToLocalTime().ToString();//2005-11-5 21:21:25
// Label5.Text = dt.ToLongDateString().ToString();//2005年11月5日
// Label6.Text = dt.ToLongTimeString().ToString();//13:21:25
// Label7.Text = dt.ToOADate().ToString();//38661.5565508218
// Label8.Text = dt.ToShortDateString().ToString();//2005-11-5
// Label9.Text = dt.ToShortTimeString().ToString();//13:21
// Label10.Text = dt.ToUniversalTime().ToString();//2005-11-5 5:21:25
// 2005-11-5 13:30:28.4412864
// Label1.Text = dt.Year.ToString();//2005
// Label2.Text = dt.Date.ToString();//2005-11-5 0:00:00
// Label3.Text = dt.DayOfWeek.ToString();//Saturday
// Label4.Text = dt.DayOfYear.ToString();//309
// Label5.Text = dt.Hour.ToString();//13
// Label6.Text = dt.Millisecond.ToString();//441
// Label7.Text = dt.Minute.ToString();//30
// Label8.Text = dt.Month.ToString();//11
// Label9.Text = dt.Second.ToString();//28
// Label10.Text = dt.Ticks.ToString();//632667942284412864
// Label11.Text = dt.TimeOfDay.ToString();//13:30:28.4412864
// Label1.Text = dt.ToString();//2005-11-5 13:47:04
// Label2.Text = dt.AddYears(1).ToString();//2006-11-5 13:47:04
// Label3.Text = dt.AddDays(1.1).ToString();//2005-11-6 16:11:04
// Label4.Text = dt.AddHours(1.1).ToString();//2005-11-5 14:53:04
// Label5.Text = dt.AddMilliseconds(1.1).ToString();//2005-11-5 13:47:04
// Label6.Text = dt.AddMonths(1).ToString();//2005-12-5 13:47:04
// Label7.Text = dt.AddSeconds(1.1).ToString();//2005-11-5 13:47:05
// Label8.Text = dt.AddMinutes(1.1).ToString();//2005-11-5 13:48:10
// Label9.Text = dt.AddTicks(1000).ToString();//2005-11-5 13:47:04
// Label10.Text = dt.CompareTo(dt).ToString();//0
//// Label11.Text = dt.Add(?).ToString();//问号为一个时间段
// Label1.Text = dt.Equals("2005-11-6 16:11:04").ToString();//False
// Label2.Text = dt.Equals(dt).ToString();//True
// Label3.Text = dt.GetHashCode().ToString();//1474088234
// Label4.Text = dt.GetType().ToString();//System.DateTime
// Label5.Text = dt.GetTypeCode().ToString();//DateTime
// Label1.Text = dt.GetDateTimeFormats('s')[0].ToString();//2005-11-05T14:06:25
// Label2.Text = dt.GetDateTimeFormats('t')[0].ToString();//14:06
// Label3.Text = dt.GetDateTimeFormats('y')[0].ToString();//2005年11月
// Label4.Text = dt.GetDateTimeFormats('D')[0].ToString();//2005年11月5日
// Label5.Text = dt.GetDateTimeFormats('D')[1].ToString();//2005 11 05
// Label6.Text = dt.GetDateTimeFormats('D')[2].ToString();//星期六 2005 11 05
// Label7.Text = dt.GetDateTimeFormats('D')[3].ToString();//星期六 2005年11月5日
// Label8.Text = dt.GetDateTimeFormats('M')[0].ToString();//11月5日
// Label9.Text = dt.GetDateTimeFormats('f')[0].ToString();//2005年11月5日 14:06
// Label10.Text = dt.GetDateTimeFormats('g')[0].ToString();//2005-11-5 14:06
// Label11.Text = dt.GetDateTimeFormats('r')[0].ToString();//Sat, 05 Nov 2005 14:06:25 GMT
Label1.Text = string.Format("{0:d}",dt);//2005-11-5
Label2.Text = string.Format("{0:D}",dt);//2005年11月5日
Label3.Text = string.Format("{0:f}",dt);//2005年11月5日 14:23
Label4.Text = string.Format("{0:F}",dt);//2005年11月5日 14:23:23
Label5.Text = string.Format("{0:g}",dt);//2005-11-5 14:23
Label6.Text = string.Format("{0:G}",dt);//2005-11-5 14:23:23
Label7.Text = string.Format("{0:M}",dt);//11月5日
Label8.Text = string.Format("{0:R}",dt);//Sat, 05 Nov 2005 14:23:23 GMT
Label9.Text = string.Format("{0:s}",dt);//2005-11-05T14:23:23
Label10.Text = string.Format("{0:t}",dt);//14:23
Label11.Text = string.Format("{0:T}",dt);//14:23:23
Label12.Text = string.Format("{0:u}",dt);//2005-11-05 14:23:23Z
Label13.Text = string.Format("{0:U}",dt);//2005年11月5日 6:23:23
Label14.Text = string.Format("{0:Y}",dt);//2005年11月
Label15.Text = string.Format("{0}",dt);//2005-11-5 14:23:23
Label16.Text = string.Format("{0:yyyyMMddHHmmssffff}",dt);
C# 时间(几个常用时间,程序运行计时,页面运行计时)
1.DateTime
DateTime now = System.DateTime.Now;
now.ToString(); //显示: 2006/08/30 17:31:02
now.ToString("yyyy-MM-dd hh:mm:ss"); //显示: 2006-08-30 05:39:11
System.DateTime.MaxValue.ToString(); //显示: 9999/12/31 23:59:59
System.DateTime.MinValue.ToString(); //显示: 0001/01/01 0:00:00
now.ToLongDateString(); //显示: 2006年8月30日
now.ToLongTimeString(); //显示: 17:34:23
now.ToShortTimeString(); //显示: 17:34
now.ToString() + " " + now.Millisecond.ToString(); //显示: 2006/08/30 17:35:19 484
2.程序运行时间:(单位 : 毫秒)
System.Diagnostics ; //名称空间
int x = 0;
int nu = 0;
Stopwatch sw = new Stopwatch();
sw.Start();
//程序开始
for (int i = 0; i < 1000000; i++)
{
x += i;
}
//程序结束
sw.Stop();
this.label1.Text += ",sum=" + x.ToString();
MessageBox.Show(sw.ElapsedMilliseconds.ToString());
3.计算一个页面执行时间:
在Global.asax.cs文件中增加以下代码:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
Application["StartTime"] = System.DateTime.Now;
}
protected void Application_EndRequest(Object sender, EventArgs e)
{
System.DateTime startTime = (System.DateTime)Application["StartTime"];
System.DateTime endTime = System.DateTime.Now;
System.TimeSpan ts = endTime - startTime;
Response.Write("页面执行所用时间:" + ts.Milliseconds + " 毫秒");
}
发表评论
-
invoke
2013-03-15 15:53 0object Object.Invoke(Delegate ... -
JQuery的WebServices调用
2013-03-14 14:12 0http://blog.sina.com.cn/s/blog_ ... -
c# list和string
2012-10-26 15:16 944C# List和String互相转换 (2011-06- ... -
.net mysql-connector-net
2012-10-19 11:10 977引用DLL引用 mysql-connector-net包中的M ... -
c# 操作mysql
2012-10-19 10:21 899using System;using System.Confi ... -
c# DataTable.copy .clone
2012-10-17 18:17 4091C# DataTable.Copy()和.Clone()的使用 ... -
C#中避免相同MDI子窗口重复打开的方法(转)
2012-10-17 13:40 1106方法一: 直接检测 ... -
C# 中使用JSON - DataContractJsonSerializer
2012-10-11 14:47 664http://www.cnblogs.com/coderzh/ ... -
.NET WHERE子句用途
2012-05-04 14:52 1490where 子句用于指定类型约束,这些约束可以作为泛型声明 ... -
c#泛型
2012-05-04 14:51 1023http://hjf1223.cnblogs.com/arch ... -
汉字转换成拼音的类(转)
2012-02-27 16:41 62064引用地址: http://blog.csdn.net/huig ... -
ASP.NET内置对象(转)
2011-12-08 13:53 3110http://www.cnblogs. ... -
asp.net webservice
2011-12-04 15:22 1809asp.net webservice 概述与 ... -
iis发布asp.net网站(转)
2011-11-23 10:32 3320iis发布asp.net 网站 ... -
win7 里配置iis 和asp.net步骤,及发布asp.net网站全程(转)
2011-11-23 10:15 5478分享 win7 里配置 iis 和a ... -
类似Windows Search的文件搜索系统
2011-11-23 09:42 1285转自:http://www.cnblogs.com/wu ... -
操作PDF文档功能的相关开源项目探索—iTextSharp 和PDFBox
2011-11-23 09:40 1948转自www.th7.cn第七城市 操作 PDF 文档功 ... -
pdf
2011-12-10 13:28 1156http://www.cnblogs.com/q1490722 ... -
iis asp.net安装顺序
2011-11-17 13:47 909如果先安装IIS再安装 .Net Framework。一切OK ... -
IIS配置
2011-11-17 13:18 782http://bbs.51cto.com/thread-488 ...
相关推荐
String.Format( "yyyy-MM-dd ",yourDateTime); 4.用Convert方法转换日期显示格式: Convert.ToDateTime("2005-8-23").ToString ("yyMMdd",System.Globalization.DateTimeFormatInfo.InvariantInfo); //支持繁体...
C#时间格式化Datetime.ToString参数format格式详细用法,本文将进行介绍,感兴趣的朋友可以了解下啊
有时候我们要对C#时间进行转换,达到不同的显示效果 默认格式为:2005-6-614:33:34 如果要换成成200506,06-2005,2005-6-6或更多的该怎么办呢 我们要用到:DateTime.ToString的方法(String,IFormatProvider) 代码如下:...
C# 日期函数 string.Format DateTime dt = DateTime.Now; Label1.Text = dt.ToString();//2005-11-5 13:21:25 Label2.Text = dt.ToFileTime().ToString();//127756416859912816 Label3.Text = dt.ToFileTimeUtc()...
datetime类型在tostring(),format的格式设置
如果大家做的项目中有多语言的需求的话,那么肯定少不了会有的功能要显示一个时间,由于文差异域每种语言用户对时间格式的需求肯定是不一样的,比如英文中的时间格式是:12/2/2013 8:20:22 PM,而德语的格式是:...
C# String Format Tester是一个用来测试字符串格式化输出的小工具。工具很简单,可以用来测试DateTime、Int16、Int32、Int64、Decimal、Single、Double、Byte、Guid 这几个类型的ToString格式化输出。此工具还集成了...
如上图所示,日期显示为”MM月DD日”,或者其它格式,比如显示年、月、日 或 年月日带时间,设置如下: 1、如下图设置,日期为d,时间为t: 2、在事件里面如下写法: private void bandedGridView1_...
在C#中DateTime是一个包含日期、时间的类型,此类型通过ToString()转换为字符串时,可根据传入给Tostring()的参数转换为多种字符串格式。
richTextBox2.Text += string.Format("{0:0000}", i) + "\n"; } } 根据闰年的规则,很容易整理出规则,四年一闰; ([0-9]{2}(0[48]|[2468][048]|[13579][26]) 百年不闰,四百年再闰。 (0[48]|[2468][048]|[13579]...
有时候我们要对时间进行转换,达到不同的显示效果 默认格式为:2005-6-6 14:33:34 如果要换成成200506,06-2005,2005-6-6或更多的该怎么办呢? 我们要用到: DateTime.ToString的方法(String, ...
数字时钟,动态显示当前时间,C#源代码public string ProcessTime() { string sTime; // Get the current time int iHour = DateTime.Now.Hour; int iMin = DateTime.Now.Minute; int iSec = DateTime.Now....
数字时钟,动态显示当前时间,C#源代码 public string ProcessTime() { string sTime; // Get the current time int iHour = DateTime.Now.Hour; int iMin = DateTime.Now.Minute; int iSec = DateTime.Now....
有时候我们要对时间进行转换,达到不同的显示效果 默认格式为:2005-6-6 14:33:34 如果要换成成200506,06-2005,2005-6-6或更多的该怎么办呢 我们要用到:DateTime.ToString的方法(String, IFormatProvider) using ...
C#时间/日期格式大全,C#时间/日期函数大全 有时候我们要对时间进行转换,达到不同的显示效果 默认格式为:2005-6-6 14:33:34 如果要换成成200506,06-2005,2005-6-6或更多的该怎么办呢? 我们要用到: 代码如下:...
为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007-01-03 14:33:34 ,要转化为其他格式,要用到DateTime.ToString的方法(String, IFormatProvider),如下所示: 代码如下:using System;using ...
1.4.7 DateTime结构——表示时间上的一刻 50 1.4.8 DAY函数——返回日期部分的整数 51 1.4.9 DayOfWeek属性——获取星期几 52 1.4.10 Equals方法——比较两个字符串对象 53 1.4.11 First函数——返回查询结果的第一...
之前曾经上传过一个农历处理类,但遇到... return string.Format(@"{0} {1} 农历 {2} 当前时间:{3}", DateTime.Now.ToString("yyyy年MM月dd日"), dt.LongCNWeek, dt.CNDate, DateTime.Now.ToString("HH:mm:ss")); }
#学习的101个经典例子,例子个个经典,涵盖C#的方方面面,带有说详尽的注释 Advanced - Multithreading - How-To Async Calls Advanced - Remoting - How-To TCP Remoting Advanced - Serialization - How-To ...