So I’m doing codecademy and the current section I’m on wants you to return the current time and display different messages depending on the current time.
You could pass with any time but I’d rather configure it to be my timezone and even extra if anyone knows, the time zone that the person accessing the web page is in.
Currently I have this.
var d = new Date();
console.log(d);
This prints GMT time.
What I’d like is GMT +10.
I knows there’s a function that returns your timezone
var n = d.getTimezoneOffset();
But I’m not too sure as to how I get this to interact with the Date function so that it prints the time in this timezone.
Thanks!
Regards,
Matt
SOLVED: Was a bug in codecademy.
Use the Date methods.
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
For example,
d.getDate()will return the local date, whereasd.getUTCDate()will return the GMT-based date.