Javascript code to convert date to timestamp

This is not everyday that you need a Javascript function to convert the date and time string to UNIX timestamp. But if you do need this like me, then here it is:

function covertToUnixTime(yourDate) {
//Subtract 1 from month to accomodate the month start from 0 in the function
return new Date(yourDate.substring(6, 10), ((yourDate.substring(0, 2) * 1) - 1), yourDate.substring(3, 5), 12,0,10,1000).getTime() / 1000;
}

Scroll to top