CSharp examples for System:DateTime Timestamp
Returns a specially formatted date stamp
using System.Collections; using System;/* ww w . j a v a2 s . c om*/ public class Main{ #endregion #region -------- PUBLIC - GetRFCDateStamp -------- /// <summary> /// Returns a specially formatted date stamp /// </summary> /// <param name="date">The date for which the stamp is generated</param> /// <returns></returns> public static string GetRFCDateStamp(DateTime date) { string dayName = Convert.ToString(date.DayOfWeek).Substring(0, 3); string dayNum = Convert.ToString(date.Day); if (date.Day < 10) dayNum = "0" + dayNum; string month = GetMonthName(date.Month); if (month.Length > 3) month = month.Substring(0, 3); string year = Convert.ToString(date.Year); string hh, mm, ss; if (date.Hour <= 9) hh = "0" + Convert.ToString(date.Hour); else hh = Convert.ToString(date.Hour); if (date.Minute <= 9) mm = "0" + Convert.ToString(date.Minute); else mm = Convert.ToString(date.Minute); if (date.Second <= 9) ss = "0" + Convert.ToString(date.Second); else ss = Convert.ToString(date.Second); string offset = ""; int off = TimeZone.CurrentTimeZone.GetUtcOffset(date).Hours; string sign = "-"; if (off > 0) sign = "+"; else off *= -1; if (off < 9) offset = sign + "0" + Convert.ToString(off) + "00"; else offset = sign + Convert.ToString(off) + "00"; string time = hh + ":" + mm + ":" + ss; return dayName + ", " + dayNum + " " + month + " " + year + " " + time + " " + offset; } }