Well, I fetch timestamp from my table using a php page with getJSON. Here is the structure.
main.php --> using getJSON (abc.php) --> value from my table
Is there any way to convert this UNIX timestamp into this format:
dd-mm-yyyy at hh:mm am
The Unix timestamp is the number of seconds elapsed since 1970 (epoch). You would need to convert that to a date object in JS:
var date = new Date(unixTimestamp*1000); // *1000 because of date takes milliseconds
Once you have the date object, you can use any of the techniques mentioned in the following post: How to format a JavaScript date
var dt=eval(unixtimestamp*1000);
var myDate = new Date(dt);
return(myDate.toLocaleString());
this will give an output like:10/27/2014, 12:58:45 PM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With