Formatting localized date in the browser
Nicolas Galler | August 31, 2007Well the closest I could get to this without making it a major ordeal was to use a VBScript section… I need something like “toLocaleShortDateString” in the Javascript but that doesn’t seem to exist (presumably because the short date format may not be defined on all OS’s). Obviously this will only work on IE.
<script language="vbscript">
Function formatShortDate(d)
formatShortDate = FormatDateTime(d, vbShortDate)
End Function
</script>
<script language="JavaScript">
alert(formatShortDate("2007-08-01 21:22:32"));
</script>
Oh yeah, FormatDateTime() won’t eat a Javascript Date object, and neither will CDate(). It has to be a string.





