string.Format("{0:F2}",str1) 字作串取两位两位小数的浮点数。 string.Format("{0:P2}",str1) 字符串取百分比。"P":表示百分比,"2":表示取小数点的位数。 日期格式符 var str=DateTime.Now; var time=string.Format({0},yyyy-MM-dd HH:mm:ss) var time=str.ToString("yyyy-MM-dd"); var ti...
string.Format("{0,50}", theObj);//格式化成50个字符,原字符右对齐,不足则补空格 6、日期格式化 string.Format("{0:d}",System.DateTime.Now) 结果为:2009-3-20 (月份位置不是03) string.Format("{0:D}",System.DateTime.Now) 结果为:2009年3月20日 string.Format("{0:f}",System.DateTime.Now...
/// 格式化时间 /// </summary> /// <param name="seconds">秒</param> /// <returns></returns> public static string FormatTime(float seconds) { TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(seconds)); string str = ""; if (ts.Hours > 0) { str = ts.Hours.ToString("00")...
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...
Time.captureFramerate = frameRate; // 创建文件夹 System.IO.Directory.CreateDirectory(folder); } void Update () { // 将文件名附加到文件夹名(格式为"0005 shot.png"") string name = string.Format("{0}/{1:D04} shot.png", folder, Time.frameCount ); // 将截屏捕获到指定的文件。 Applicat...
returnstring.Format("{0}天前", (int)Math.Floor(span.TotalDays)); } elseif(span.TotalHours > 1) { returnstring.Format("{0}小时前", (int)Math.Floor(span.TotalHours)); } elseif(span.TotalMinutes > 1) { returnstring.Format("{0}分钟前", (int)Math.Floor(span.TotalMinutes)); ...
传入时间戳t(t= 当前时间戳() - 指定时间的时间戳 )/// </summary>/// <param name="t"></param>/// <returns></returns>publicstringGetTimeLongAgo(double t){string str="";double num;if(t<60){str=string.Format("{0}秒前",t);}elseif(t>=60&&t<3600){num=Math.Floor(t/60);str...
23/04/07 10:20:41) (Standard date and time string ) - see below for using os.setlocale to get the correct locale. %d - Day of month as decimal number (01 - 31) %H - Hour in 24-hour format (00 - 23) %I - Hour in 12-hour format (01 - 12) %j - Day of year as decimal...
("Shot",GUILayout.Width(200f),GUILayout.Height(50f))){chronometer.Shot();}if(GUILayout.Button("Log",GUILayout.Width(200f),GUILayout.Height(50f))){varrecords=chronometer.Records;for(int i=0;i<records.Count;i++){Debug.Log(string.Format("No.{0}: {1}",i+1,records[i].time));}...
private string timeStr = string.Empty; void Update () { timer += Time.deltaTime; if (timer >= 1f) {s++; timer = 0;} if (s >= 60) {m++;s = 0;} if (m >= 60) {h++;m = 0;} if (h >= 99) {h = 0;} } void OnGUI(){ timeStr = string.Format ("{0:D2}:...