I’m using several literals to inject the user’s time onto the the page. The values in the HTML are the UTC times.
var TheDay = parseInt($('#UserDayToday').html(), 10);
var TheMonth = parseInt($('#UserMonthToday').html(), 10);
var TheYear = parseInt($('#UserYearToday').html(), 10);
var TheHours = parseInt($('#UserTimeStampHours').html(), 10);
var TheMinutes = parseInt($('#UserTimeStampMinutes').html(), 10);
Now I want to build a time stamp with that time so I tried this:
var TheDateToday = new Date();
TheDateToday.setUTCFullYear(TheYear, TheMonth, TheDay);
TheDateToday.setUTCHours(TheHours, TheMinutes, 0, 0);
alert(TheDateToday);
When the alert comes on, it gives me the time with his timezone shift added. How can I just have the the UTC time. I know I can get it from the browser but I want to get the UTC time built from the data sent from the server, not retrieved from the user’s machine by the browser.
Thanks
You are displaying the date in local time. Use the
toUTCStringmethod instead of the implicittoStringmethod: