Convert full time string to Unix timestamp in jQuery / javascript -
i need produce timestamp of each date/time string gets produced in foreach loop.
how turn string mon aug 08 2016 10:09:42 gmt+0100 (bst)
unix timestamp comparison?
i going use single value jquery sort (code below)
var boards = $(".socialbox"); boards.sort(function(a, b){ return $(a).data("date") - $(b).data("date"); }); $("#social-board").html(boards);
as can imagine above code doesn't work on current date/time string.
you can convert string data date object along .gettime()
number of milliseconds since 1970/01/01:
boards.sort(function(a, b){ return new date($(a).data("date")).gettime() - new date($(b).data("date")).gettime(); });
Comments
Post a Comment