Not exactly sure where i found this, but it has helped me on numerous occasions to format dates when servers are in South Africa and when they need to be moved to USA servers. Hope this helps you too.

<%

ReturnDateTime 1033, “English (US)”

ReturnDateTime 2057, “English (UK)”

ReturnDateTime 3081, “English (Australia)”

ReturnDateTime 1031, “German”

Sub ReturnDateTime(locale, description)

Session.LCID = locale

Response.Write “<b>” & description & ” (LCID = ” & locale & “)</b><br>”

Response.Write “Long date: ” & FormatDateTime(Date, 1) & “<br>”

Response.Write “Short date: ” & FormatDateTime(Date, 2) & “<p>”

End Sub

%>

If you need to use it to call a database field then just use it like this.

<input type=”text” name=”events_date” value=”<%= formatdatetime((rsEvents.Fields.Item(“events_date”).Value),2) %>” size=”32″ />

Depending on what locale you have chosen it will either write:

English (US)

Long date: Monday, February 25, 2009

Short date: 2/25/2009

English (UK)

Long date: 25 February 2009

Short date: 25/02/2009

English (Australia)

Long date: Monday, 25 February 2009

Short date: 25/02/2009

German

Long date: Montag, 25. Februar 2009

Short date: 25.02.2009

I hope that helps you.

About Paul Ogier

Paul Ogier has written 202 posts.

Paul Ogier is an IT Guru, Website Developer, and generally a nice guy. He loves code and he loves design.

Incoming search terms for the article: