Javascript Convert Date Time string to Epoch

cbm64 picture cbm64 · Dec 4, 2012 · Viewed 97.3k times · Source

so I give up...been trying to do this all day;

I have a string that supplies a date and time in the format dd/MM/yyyy hh:mm (04/12/2012 07:00).

I need to turn that into an Epoch date so I can do some calculations upon it. I cannot modify the format in which the date time is sent to me.

JavaScript or jQuery is fine.

Answer

Crayon Violent picture Crayon Violent · Dec 4, 2012
var someDate = new Date(dateString);
someDate = someDate.getTime();