formatting DateTime

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear :

i have the following datetime in string

string sDateTime = "26/1/2005 10:18:30 AM";

and I need to get the same datetime with the following format

Wed, 26 Jan 2005 10:18:30 +0200

How can I format string to get the needed format
 
string sDateTime = "26/1/2005 10:18:30 AM";

and I need to get the same datetime with the following format

Wed, 26 Jan 2005 10:18:30 +0200

How can I format string to get the needed format

Not too sure about the +0200 at the end, but you can format the rest of it
like so:

string sDateTime = "26/1/2005 10:18:30 AM";
sDateTime = Convert.ToDateTime(sDateTime).ToString("ddd, dd MMM yyyy
HH:mm:ss");
 
System.Convert.ToDateTime(sDateTime).ToString("ddd, d MMM yyyy hh:mm:ss
zzz");

Eliyahu
 
Note that if you're doing the conversion on a system set to US culture,
you'll need to adjust for that to properly decode dates in the dd/mm/yyyy
format (US is mm/dd/yyyy).
 
Back
Top