I've got a small custom made blog type thing and want to display the date posted next to comments.  I'd like to do it in the format of:  posted 23 secs ago posted 43mins ago posted 1hr ago posted 1day ago posted  2 weeks ago ... probably won't get much longer than that because articles older than a month aren't shown.  I can stored the actual date in datetime or timestamp format in MySQL...  Anyone know of a function that's existing for PHP which I could use to do this? I haven't really found anything that suits yet.
4268
Given a specific DateTime value, how do I display relative time, like:   2 hours ago 3 days ago a month ago
36605
Looking at , I see "asked yesterday" (which I really hate; I'd like to see an exact time specification rather than this vague one, especially in the list of questions). But it was not asked yesterday! When I hover over it to show the exact time, it shows it was actually the day before yesterday!  This snapshot was taken at 2012-03-31 15:00 UTC (plus or minus a few minutes):    Whatever different opinions you may have on the implementation, yesterday is a word with a certain meaning. Redefining it is not a good idea. At least rephrase this as "1 day ago" or something.
96817
How do you display the archives of a Custom Post Type by Year &amp; Month?
69738
I went to check some of my queries against UNIX &amp; Linux this morning and noticed that the results all had dates older than a week. Going to   query, I see that U&amp;L is among the sites whose most recent posts/comments are 2020-04-19 instead of 2020-04-26, as expected. Partial results of incompletely-refreshed sites are:  ... StackExchange.Meta                    2020-04-19 05:15:09 comments  StackExchange.Ubuntu                  2020-04-19 05:08:40 comments  StackExchange.Stats                   2020-04-19 05:06:54 comments  StackExchange.Ubuntu                  2020-04-19 05:02:17 posts     StackExchange.Programmers             2020-04-19 04:51:22 comments  StackExchange.Programmers             2020-04-19 04:48:14 posts     StackExchange.Gaming                  2020-04-19 04:46:57 posts     StackExchange.Stats                   2020-04-19 04:40:08 posts     StackExchange.Meta                    2020-04-19 04:36:48 posts     StackExchange.English                 2020-04-19 04:34:46 comments  StackExchange.Math                    2020-04-19 04:32:38 comments  StackExchange.Tex                     2020-04-19 04:25:59 posts     StackExchange.Math                    2020-04-19 04:22:14 posts     StackExchange.Tex                     2020-04-19 04:19:32 comments  StackExchange.Unix                    2020-04-19 04:17:12 comments  StackExchange.English                 2020-04-19 04:15:42 posts     StackExchange.Unix                    2020-04-19 04:15:31 posts     StackExchange.Gis                     2020-04-19 04:14:44 posts     StackExchange.Electronics             2020-04-19 04:11:13 comments  ...   Sorting by date doesn't make it obvious to me where the refresh died/stopped, but hopefully this post alerts the correct people.
87792
I asked  yesterday, approximately 18 hours ago ("2011-12-13 20:24:03Z" according to the hover text), and it's still being displayed as "today".  I assume the "Z" in the timestamp refers to Zulu time, so I , and the date (2011-12-14) differs from the timestamp on the question.  I don't pretend to understand all of the complexities when converting time zones, but I thought it was strange enough to report. If it matters at all, I'm in US-Eastern.
40410
Something similar to Unix's timestamp, that is a single number that represents the current time and date. Either as a number or a string.
35451
I'm trying to extend an RSS feed to output some post-meta from my website.  I have an 'event_date' meta-key and I need to order by this as opposed to the RSS standard publish date, which I know how to do if I could get that information.  I'm using the following code, which makes use of the Wordpress action hooks available in the RSS feeds. However, when I use these hooks, the feeds report that there are no items found, while without these the items are found, but of course I cannot order them as I need.  Am I doing something wrong in the way that I am outputting to the RSS feed?  /**  * Adds the 'event_date' meta value to a feed  */ add_action('atom_entry', 'add_event_date_to_feed'); add_action('rdf_item', 'add_event_date_to_feed'); add_action('rss_item', 'add_event_date_to_feed'); add_action('rss2_item', 'add_event_date_to_feed'); function add_event_date_to_feed(){      global $post;      $event_date_raw = get_post_meta($post-&gt;ID, 'event_date', true);     if($event_date_raw &amp;&amp; $event_date_raw !== '') :         $date_object = DateTime::createFromFormat('D, d M Y H:i:s +0000', $event_date_raw);         $event_date = $date-&gt;format('U');     else :          $event_date = '';     endif;     printf("\t\t".'&lt;eventDate&gt;%1$s&lt;/eventDate&gt;'."\n", $event_date);  }
23049
Using standard mysql functions is there a way to write a query that will return a list of days between two dates.  eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values:   2009-01-01   2009-01-02   2009-01-03  2009-01-04   2009-01-05  2009-01-06  2009-01-07  2009-01-08   2009-01-09  2009-01-10  2009-01-11  2009-01-12  2009-01-13   Edit: It appears I have not been clear. I want to GENERATE this list. I have values stored in the database (by datetime) but want them to be aggregated on a left outer join to a list of dates as above (I am expecting null from the right side of some of this join for some days and will handle this).
77368
Some issues with timezones in PHP have been in the back of my mind for a while now, and I was wondering if there are better ways to handle it than what I'm currently doing.  All of the issues revolve around reformating database stored dates:  When dealing with a site that has to support multiple timezones (for users), to normalize the timezone offest of stored timestamps I always store it with the server timezone using the CURRENT_TIMESTAMP attribute or the NOW() function.   This way I don't have to consider what timezone was set for PHP when the timestamp was entered (since PHP time functions are timezone aware). For each user, according to his preference I set the timezone somewhere in my bootstrap file using:  date_default_timezone_set($timezone);   When I'm looking to format dates with the php date() function, some form of conversion has to take place since MySQL currently stores timestamp in the format Y-m-d H:i:s. With no regard to timezone, you could simply run:  $date = date($format,strtotime($dbTimestamp));   The problem with this is that date() and strtotime() are both timezone aware functions, meaning that if the PHP timezone is set differently from the server timezone, the timezone offset will apply twice (instead of once as we would like).  To deal with this, I usually retrieve MySQL timestamps using the UNIX_TIMESTAMP() function which is not timezone aware, allowing my to apply date() directly on it - thereby applying the timezone offset only once.  I don't really like this 'hack' as I can no longer retrieve those columns as I normally would, or use * to fetch all columns (sometimes it simplifies queries greatly). Also, sometimes it's simply not an option to use UNIX_TIMESTAMP() (especially when using with open-source packages without much abstraction for query composition).  Another issue is when storing the timestamp, when usage of CURRENT_TIMESTAMP or NOW() is not an option - storing a PHP generated timestamp will store it with the timezone offset which I would like to avoid.  I'm probably missing something really basic here, but so far I haven't been able to come up with a generic solution to handle those issues so I'm forced to treat them case-by-case. Your thoughts are very welcome
67969
I have a custom search form that I posts a year + month, such as 2014-04 I would like to get all nodes created that month, when I create the timestmap I use: "SELECT .......         AND changed >= 'strtotime($date)'"  This is the code for form date:  $form['aqar_date'] = array( '#type' =&gt; 'date_select',  '#title' =&gt; t('Date'), '#prefix' =&gt; '&lt;div id="space_replace" class="search-title-date"&gt;   &lt;h2&gt;Node date&lt;/h2&gt;', '#suffix' =&gt; '&lt;/div&gt;',      '#date_format' =&gt; 'Y-m', '#default_value' =&gt; date('Y-m'), '#date_year_range' =&gt; '-4:+0',  );   This is the form submit:  $start_date = strtotime($date); $query = " SELECT `nid` FROM `node` WHERE  `type` = 'custom'  AND `changed` &gt;= '$start_date'";   But I'm not getting, I need a way to specify to only this month period not this month and newer!  Thanks!
90473
I want to know if I can hide the values of a date field if the values are older than a certain time. The website is built with Drupal 7, and Display Suite.
9505
Let me explain you the problem   $ date +%c -d "$d" Tue 31 Dec 2013 01:13:06 PM CET $ date +'Today is %F' -d "$d" Today is 2013-12-31   This solution corresponds to current date.  But I have one variable which stores date other than current date  $Prev_date="Wed Dec 25 06:35:02 EST 2013"    I am looking for solution to read this date as 2013-12-25 and store it in a variable.  I have tried this:  a=`date --date=$Prev_date '+%y/%m/d'` echo $a   It's giving this error:  date: illegal option -- date=Wed usage: date [-u] mmddHHMM[[cc]yy][.SS] date [-u] [+format] date -a [-]sss[.fff]
58115
In question results list, the dates/timestamps should be shown the same way as they are on the site. I.e., when sorting by newest, then show the "asked" date, but sorting by activity should show the last modified date.   In other words, show the user the date that the app is actually sorting by.  (Adding "asked" or "modified" before the date might be good, if space-consuming.)      Example of how the site does it:
65366
I have a table of events with a recorded start and end time as a MySQL DATETIME object (in the format YYYY-MM-DD HH:MM:SS. I want to find all events that occur in a specific date range. However, events can span multiple days (and go outside of my date range, but I want to return them if they even overlap by 1 second or more with my date range).  Suggestions?
93427
What is the best way to remove the post date from a views created RSS feed? I have a calendar that I have created a feed for, but it is being sorted by a cck date value, making the post date not necessarily accurate.  Is there an easy way to remove this from within views (D6), or would this need to be a template change?
110583
I'd like to change the date format that is used for articles in Drupal 8. It looks like it uses the Default medium date format by default. I added my own format at admin/config/regional/date-time, but I  can't find where to edit the format that articles use.   Is there a way to do this from the CMS or does this need to be done in code?
102168
I'm trying to create a archive list with only my "normal" post format articles (not link, aside, quote, etc formats).  How would I implement has_post_format( 'standard' ), or something similar, into the code below?  I haven't been able to find a query for get_posts that only requests specific format types.  &lt;?php         // Get the posts     $myposts = get_posts('numberposts=-1&amp;orderby=post_date&amp;order=DESC');      ?&gt;  &lt;?php foreach($myposts as $post) : ?&gt;     &lt;?php         // Setup the post variables     setup_postdata($post);      $year = mysql2date('Y', $post-&gt;post_date);     $month = mysql2date('n', $post-&gt;post_date);     $day = mysql2date('j', $post-&gt;post_date);     ?&gt;  &lt;p&gt;     &lt;span class="the_article"&gt;         &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;     &lt;/span&gt;     &amp;nbsp;&amp;nbsp;&amp;nbsp;     &lt;span class="the_day"&gt;         &lt;?php the_time('j F Y'); ?&gt;     &lt;/span&gt; &lt;/p&gt;  &lt;?php endforeach; ?&gt;   My php skills are at the beginner level at best, so any help would be much appreciated.