Im writing a mvc4 application that will be used globally. Part of the application is recording when a transaction was added or modified.
So I am saving the transaction datetime as UTC. from the clientside whats my best way to display the date as they are expecting?
Is this a javascript function I should be using or should I be doing something within the view?
Internally, javascript date objects store the time as a number of milliseconds since an epoch UTC (1970-01-01T00:00:00Z). The simplest way to transfer time is using that number, so:
Alternatively, you can pass a UTC timestamp, split it into its components and convert it to a date object using Date.UTC. Note that months are zero based so one must be subtracted from the calendar month number.
To get the UTC millisecond value for a local time, use Date.prototype.getTime. For the example above: