I'm trying to parse the following date:
Tue, 27 Oct 2015 00:00:00 GMT
this is my code:
start = Date.parse(currDateStart.toString('dd/MM/yyyy')
+ ' ' + workingDay.start, 'dd/MM/yyyy HH:mm');
where currDateStart is the date that I want parse (see above), and working.start
contains : 09:00
so the final result should be:
Tue, 27 Oct 2015 09:00:00 GMT
but instead I get null
why?
Neither
moment
orDate
will accept a format parameter in thetoString
function.Assuming
curreDateStart
and the outputstart
are bothmoment
objects, then you should do this:If you wanted
Date
orstring
output, you could calltoDate
orformat
from there.If the input is something besides a
moment
object, then create amoment
object from it first, such asmoment(currentDateStart)
if it's aDate
, ormoment.utc(currentDateStart, "ddd, DD MMM YYYY HH:mm:ss")
if its astring
in GMT.