Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting a Date/Time in C#

I have a date/time string that looks like the following:

Wed Sep 21 2011 12:35 PM Pacific

How do I format a DateTime to look like this?

Thank you!

like image 906
user609886 Avatar asked Nov 29 '22 04:11

user609886


1 Answers

The bit before the time zone is easy, using a custom date and time format string:

string text = date.ToString("ddd MMM dd yyyy hh:mm t");

However, I believe that the .NET date/time formatting will not give you the "Pacific" part. The best it can give you is the time zone offset from UTC. That's fine if you can get the time zone name in some other way.

A number of TimeZoneInfo identifiers include the word Pacific, but there isn't one which is just "Pacific".

like image 85
Jon Skeet Avatar answered Dec 10 '22 17:12

Jon Skeet