relative-date

How to use Moment.js?

廉价感情. 提交于 2019-11-27 18:48:57
I'm unable to follow the Moment.js documentation , and need some help with setting it up. I've referenced the moment.min.js file properly on my webpage like so: <script src="/js/moment.min.js"></script> Coming to the HTML part of my webpage, I have two different datetime's on the same page: Published Date <time class="pubdate" datetime="2012-06-09T12:32:10-04:00" pubdate> June 09, 2012 </time> Last Modified Date <time class="updated" itemprop="dateModified" datetime="2012-06-09T12:32:10-04:00"> June 9, 2012 ~ 12:32 </time> Important! The relative date parsing shouldn't go beyond "yesterday".

How to use Moment.js?

时间秒杀一切 提交于 2019-11-26 19:30:20
问题 I'm unable to follow the Moment.js documentation, and need some help with setting it up. I've referenced the moment.min.js file properly on my webpage like so: <script src="/js/moment.min.js"></script> Coming to the HTML part of my webpage, I have two different datetime's on the same page: Published Date <time class="pubdate" datetime="2012-06-09T12:32:10-04:00" pubdate> June 09, 2012 </time> Last Modified Date <time class="updated" itemprop="dateModified" datetime="2012-06-09T12:32:10-04:00"

Javascript timestamp to relative time (eg 2 seconds ago, one week ago etc), best methods?

守給你的承諾、 提交于 2019-11-26 17:13:24
I'm looking for a nice JS snippet to convert a timestamp (e.g. from Twitter API) to a nice user friendly relative time (e.g. 2 seconds ago, one week ago etc). Anyone care to share some of their favourite methods (preferably not using plugins)? Well it's pretty easy if you aren't overly concerned with accuracy. What wrong with the trivial method? function timeDifference(current, previous) { var msPerMinute = 60 * 1000; var msPerHour = msPerMinute * 60; var msPerDay = msPerHour * 24; var msPerMonth = msPerDay * 30; var msPerYear = msPerDay * 365; var elapsed = current - previous; if (elapsed <

Javascript timestamp to relative time (eg 2 seconds ago, one week ago etc), best methods?

帅比萌擦擦* 提交于 2019-11-26 05:18:22
问题 I\'m looking for a nice JS snippet to convert a timestamp (e.g. from Twitter API) to a nice user friendly relative time (e.g. 2 seconds ago, one week ago etc). Anyone care to share some of their favourite methods (preferably not using plugins)? 回答1: Well it's pretty easy if you aren't overly concerned with accuracy. What wrong with the trivial method? function timeDifference(current, previous) { var msPerMinute = 60 * 1000; var msPerHour = msPerMinute * 60; var msPerDay = msPerHour * 24; var

PHP: producing relative date/time from timestamps

旧城冷巷雨未停 提交于 2019-11-26 00:38:16
问题 I\'m basically trying to convert a Unix timestamp (the time() function) to a relative date/time that\'s both compatible with past and future date. So outputs could be: 2 weeks ago 1 hour and 60 minutes ago 15 minutes and 54 seconds ago after 10 minutes and 15 seconds First I tried to code this, but made a huge unmaintainable function, and then I searched the internet for a couple of hours, yet all I can find are scripts that produce only one part of the time (e.h: \"1 hour ago\" without the