Groups | Blog | Home
all groups > asp.net > january 2006 >

asp.net : Lazy question about displaying current time


clintonG
1/24/2006 11:59:21 PM
How do I format the current time as: 8:00 PM (GMT -06:00)

<%= Clinton Gallagher

Milosz Skalecki
1/25/2006 5:27:03 AM
Hi there lazy man :]

public string GetCustomDateString(DateTime date)
{
int difference = TimeZone.CurrentTimeZone.GetUtcOffset(date).Hours;
return string.Format(
"{0} ({1} GMT)",
date.ToString("h:mm tt"),
difference >= 0 ? "+" + difference.ToString() : difference.ToString());
}

--
Milosz Skalecki
MCP, MCAD


[quoted text, click to view]
clintonG
1/25/2006 11:03:03 AM
Hi there Milosz. Thanks...

<%= Clinton Gallagher

[quoted text, click to view]

AddThis Social Bookmark Button