No, there is no jQuery function for this. you can use
- JavaScript own
Date object, using the functions getHours() and getMinutes() , independently processing AM / PM (for example, hours> = 12 - PM), postponing minutes with leading 0, if minutes are less than 10, etc. Also note that if the clock is 0, you want to do it 12 (because when using the AM / PM style, you write midnight as “12:00 AM” rather than “0:00 AM”). - DateJS , an additional library that makes a huge amount of date materials (although, unfortunately, it is not actively supported)
- PrettyDate by John Rezig (creator of jQuery)
To use almost any of them, you first need to turn this millisecond value into a Date object. If this is really a millisecond value, first you parse the string into a number via parseInt(str, 10) , and then use new Date(num) to create a Date object representing this point in time. So:
var dt = new Date (parseInt(params.tweetDate, 10));
However, the value you specified, the value in milliseconds, seems a little strange - it's usually milliseconds since The Epoch (January 1, 1970), which uses JavaScript, but new Date(parseInt("77771564221", 10)) gives us the date in June 1972, long before Twitter. This is not a second since The Epoch (a fairly common Unix convention), because new Date(parseInt("77771564221", 10) * 1000) gives us a date in June 4434. So, the first thing to find out is what really represents the value, milliseconds since. Then adjust it so that it lasts for milliseconds with The Epoch, and pass it to new Date() to get the object.
source share