{"id":253,"date":"2011-05-14T07:59:02","date_gmt":"2011-05-14T07:59:02","guid":{"rendered":"http:\/\/www.nirvaat.com\/?p=253"},"modified":"2011-06-25T19:24:27","modified_gmt":"2011-06-25T19:24:27","slug":"javascript-code-to-convert-date-to-timestamp","status":"publish","type":"post","link":"https:\/\/nirvaat.com\/blogs\/2011\/05\/javascript-code-to-convert-date-to-timestamp\/","title":{"rendered":"Javascript code to convert date to timestamp"},"content":{"rendered":"<p><code>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:<\/code><\/p>\n<p><code>function covertToUnixTime(yourDate) {<br \/>\n\/\/Subtract 1 from month to accomodate the month start from 0 in the function<br \/>\nreturn new Date(yourDate.substring(6, 10), ((yourDate.substring(0, 2) * 1) - 1), yourDate.substring(3, 5), 12,0,10,1000).getTime() \/ 1000;<br \/>\n}<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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) [&hellip;]<\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[26],"tags":[],"class_list":["post-253","post","type-post","status-publish","format-standard","hentry","category-quick-fixes"],"_links":{"self":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts\/253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/comments?post=253"}],"version-history":[{"count":3,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts\/253\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/posts\/253\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/media?parent=253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/categories?post=253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nirvaat.com\/blogs\/wp-json\/wp\/v2\/tags?post=253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}