Johnrad Johnrad - 1 year ago 67
Javascript Question

Convert UTC time string to the user's local time

I currently have a web page where I am displaying the date a file was created as a string. Since the file is being generated on an american server, the date is in UTC.

An example date would be:

6/3/2016 10:13:55 AM

I am wanting to convert this date to the timezone of the user who visits the webpage. The web page can be visited by people all over the world.

For example, I would like the example time to display
6/4/2016 01:13:55 AM
for Australian Eastern Standard Time (AEST).

var ms = Date.parse('6/3/2016 10:13:55 AM' + ' UTC');
var date = new Date();
var timezone_shifted_string = date.toLocaleString();