Description of the Issue and Steps to Reproduce:
Moment returns time that is few minutes after time that my computer is showing.
This is how I set the time: var publishdate = moment().format('YYYY-MM-DD HH:MM');
Here is a video of it:
https://youtu.be/2ctTNhqYR0A
In the video you can see I am using bootstrap datetimepicker which it self uses momentjs, when I initialize the publishdate it's few minutes after what is on my computer, when I click in the datetimepicker and choose a date, correct time is then set.
Why does momentjs intialy give me wrong time and datepicker gives correct?
Please include the values of all variables used.
Environment:
Win 10 Chrome latest version
If you are reporting an issue, please run the following code in the environment you are using and include the output:
console.log(moment().format('YYYY-MM-DD HH:MM'))
console.log( (new Date()).toString())
console.log((new Date()).toLocaleString())
console.log( (new Date()).getTimezoneOffset())
console.log( navigator.userAgent)
console.log(moment.version)
output
2017-03-25 12:03
create: Sat Mar 25 2017 12:37:19 GMT+0100 (Romance Standard Time)
create: 3/25/2017, 12:37:19 PM
create: -60
create: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36
create: 2.18.1
Its possible this is a Bootstrap Datepicker bug. Which Datepicker are you using? Do they have a Github repository?
i doubt that it has to do with datetimepicker since this line:
console.log(moment().format('YYYY-MM-DD HH:MM')) gives
2017-03-25 12:03
and time on computer was 12:37 or something close to that, datetime picker gives correct time when it inserts time into the input box.
anyways I am using:
var publishdate = moment().format('YYYY-MM-DD HH:MM');
That second MM
should be mm
because MM means month and mm means minute.
Most helpful comment
That second
MM
should bemm
because MM means month and mm means minute.