Anyone know how to convert a Unix timestamp that looks like this - 1291668351 - into regular time using javascript? Preferably a bookmarklet?
Thanks! I'm kind of a newb when it comes to writing javascript...how can I format it to look more like a digital clock? Like 12 hour format?
Thanks! I'm kind of a newb when it comes to writing javascript...how can I format it to look more like a digital clock? Like 12 hour format?
No problem, that's why we're here. That link I added at the bottom shows more formatting choices, but here's an example:
Adding .format("M jS, Y g:i:s a") to the Date variable will cause it to spit out a format like this:
To get that, you can use this code:
javascript:ts = prompt("Unix timestamp:"); date = new Date(ts*1000); alert(date.format('"M jS, Y g:i:s a"));
"Wisdom cannot be given unless someone asks for it and shows a readiness to receive it." |
PERFECT! Thanks So much! You rock!
Olympus
Single & Not Looking
In Firefox, click your Bookmarks menu and click on "Organize bookmarks" (or CTRL+SHIFT+B)
Click on "New bookmark..." and save it on your bookmarks toolbar
Type in some name for the new bookmarklet, like "Unix Timestamp Converter", in the Name field (Fig-1)
In the Location field, paste the javascript code below ...
(Fig-2)

The Result ...
(Fig-3)

For more formatting of the output you can check out PHP.net or this page.