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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -