Question in brief:
What is the easiest way to convert date-month-year hour(24):minute
to timestamp
?
due to more views add clear question on the top, so that no need to go through background & all if need quick help.
Background :
I have a simple html table and I used jquery sorter to sort my table columns.
Everything is working fine except a date column which is having following format of data,
17-09-2013 10:08
date-month-year hour(24):minute
This column is sorting(alphabetically) but not as I expected(date wise). I tried to use a custom parser as follows,
$.tablesorter.addParser({
id: 'date_column', // my column ID
is: function(s) {
return false;
},
format: function(s) {
var timeInMillis = new Date.parse(s);
return timeInMillis;
},
type: 'numeric'
});
Problem :
it fails due to new Date.parse(s)
.
Question :
what is the easiest way to convert date-month-year hour(24):minute
to timestamp? then I can skip var timeInMillis = new Date.parse(s);
line.
Thanks
Edited :
Sorry about the confusion about milliseconds
, actually it should be the timestamp
which is a number that represents the current time and date.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…