|
Boost Testing : |
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2007-11-07 10:07:39
Beman Dawes wrote:
> A number of our reports display the report time, usually as UTC.
>
> While in theory this is fine, in practice I find it cumbersome to first
> do the mental conversion to local time, then to the 12 hour clock time
> I'm most comfortable with.
>
> Is there a relatively easy and reliable way for Javascript, or some
> other technology available in popular browsers, to display a time as
> local time?
>
Supposing you already have split it in its components, you can use:
var timestamp = new Date(Date.UTC(year, month[, date[, hours[, minutes[,
seconds[, milliseconds]]]]]));
var localform = timestamp.toLocaleString();
The representation is not exactly defined; it depends on the OS.
Sebastian Redl