string.Format("{0} {1}", DateTime.Now.ToString("ddd MMM dd yyyy HH:mm tt"), TimeZone.CurrentTimeZone.StandardName);
Turn off the standard time if you do not want to show this.
EDIT: If you need to do this everywhere, you can also extend DateTime to include a method for this.
void Main() { Console.WriteLine(DateTime.Now.MyCustomToString()); } // Define other methods and classes here public static class DateTimeExtensions { public static string MyCustomToString(this DateTime dt) { return string.Format("{0} {1}", DateTime.Now.ToString("ddd MMM dd yyyy HH:mm tt"), TimeZone.CurrentTimeZone.StandardName).Replace(" Standard Time", string.Empty); } }
You can run this example in LinqPad with a direct copy and paste and run it in program mode.
MORE EDITING
After the comments below, this is an updated version.
void Main() { Console.WriteLine(DateTime.Now.MyCustomToString()); } // Define other methods and classes here public static class DateTimeExtensions { public static string MyCustomToString(this DateTime dt) { return string.Format("{0:ddd MMM dd yyyy hh:mm tt} {1}", DateTime.Now, TimeZone.CurrentTimeZone.StandardName).Replace(" Standard Time", string.Empty); } }
source share