I’m attempting to change the UNIX 10 figure timestamps the Dark Sky API provides into a readable 24hr clock format for sunset, sunrise and current time, but I’m struggling to find an algorithm for accomplishing this. Does anybody have a solution in jQuery?
Thanks! Would it be best to use a function at the end of this line to incorporate moment.js into my code, or would I be manipulating the UNIX timestamp once the jQuery has already gathered it from the JSON and displayed it?
That seems to be working somewhat, but it’s showing what I believe is the UNIX Epoch, January 18th, 1970. I shall keep digging! We’re getting somewhere though.
EDIT: Got it working! Needed to add .unix after moment, like this:
$("#theTime").hide().html(moment.unix(data.currently.time).format("dddd, MMMM Do YYYY, h:mm:ss a")).fadeIn('slow');
Thanks for your help jenovs, moment is great to know about.