Javascript date how to convert 'dd-MMMM-yyyy' format in timestamp?

I’ve got the current date from a datepicker widget in this format


but all in all it could be a better format dd MMMM yyyy if possible

how to convert it in timestamp ?

I could map the month but it’s quite ugly ^^

Hi there,

Could you give me an example of what you have (e.g. "01-01-14) and what you want (e.g. “01 January 2014”)

Sorry if this is obvious, I’m having a slow day :slight_smile:

I’ve got


I want a timestamp like


possible with the right timezone

I found
but it doesn’t work with that format :frowning:

new Date(“26 January 2014”).getTime()


Just do this:

var date = new Date("26-January-2014"),
    timestamp = +date;


var date = new Date("26-January-2014");

give me NaN

Shouldn’t do.

What does the following command give you:

console.log(Number(new Date("26-January-2014")));

Take a closer look Pullo’s code again. You didn’t replicate the syntax properly.

it’s simply a shortcut :slight_smile:

I found the tricky point
may be or sure my ff version it’s buggy
in the console also

Number(new Date("26-January-2014"))

give me NaN
I tried it in the chrome console and it works
thanks for the snippet


It’s the hyphens in the date that FF is balking at, Chrome seems to accept them for some reason.

This will work in FF, too:

var date = new Date(("26-January-2014").replace(/-/g, " "));