I have this php code  $today_date = date('d/m/Y H:i:s'); $Expierdate = '09/06/2017 21:45:03'; $remaindate = date_diff($today_date,$Expierdate);        echo $remaindate;   and i need result from difference between two date.
3535
How to calculate minute difference between two date-times in PHP?
7708
How to add days to current Date using JavaScript. Does JavaScript have a built in function like .Net's AddDay?
22760
I have a class that processes some data returned by a query. The query is based on the createddate column of the object. In this case, the query specifically retrieves data created 3 days before today.  So as an example, the query would have the  Select Id, Name, Amount__c FROM MyCustomObject__C WHERE CreatedDate = TODAY - 3 as the condition to fetch records.  In my test class any records I insert in the MyCustomeOBject__c would always have the CreatedDate = TODAY  So how can I make test data that was created 3 days ago?
116559
I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly.  That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.  It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way.    What's the simplest way of doing this?  [Edit: Just to avoid confusion in an answer below, this is a JavaScript question, not a Java one.]
2888
I'm building a quick csv from a mysql table with a query like:  select DATE(date),count(date) from table group by DATE(date) order by date asc;   and just dumping them to a file in perl over a:  while(my($date,$sum) = $sth-&gt;fetchrow) {     print CSV "$date,$sum\n" }   There are date gaps in the data, though:  | 2008-08-05 |           4 |  | 2008-08-07 |          23 |    I would like to pad the data to fill in the missing days with zero-count entries to end up with:  | 2008-08-05 |           4 |  | 2008-08-06 |           0 |  | 2008-08-07 |          23 |    I slapped together a really awkward (and almost certainly buggy) workaround with an array of days-per-month and some math, but there has to be something more straightforward either on the mysql or perl side.   Any genius ideas/slaps in the face for why me am being so dumb?    I ended up going with a stored procedure which generated a temp table for the date range in question for a couple of reasons:   I know the date range I'll be looking for every time The server in question unfortunately was not one that I can install perl modules on atm, and the state of it was decrepit enough that it didn't have anything remotely Date::-y installed   The perl Date/DateTime-iterating answers were also very good, I wish I could select multiple answers!
101488
Alright, quick question.  A server is running in Eastern Time. PHP program needs to make date calculations using Central time.  At the moment, I am putting this line at the very top of my script:  putenv("TZ=US/Central");   Is that the best way to go about that or is there some PHP trick I'm not aware of?  Cheers.
81419
Is it possible to use the =today() function (or something else) to insert the current date but then not update each time the file is opened?  I want to create a numbers template for my invoices. I'd like it to auto fill invoice date and date due then, when I save the document, store the values, not the function.
29212
Anyone know a simple way using Java calendar to subtract X days from a date?  I have not been able to find any function which allows me to directly subtract X days from a date in Java. Can someone point me to the right direction?
73645
I wrote a little bash script that made me stumble across the . I did not know about this problem before and I just dare on posting the --debug output I got from date when my script tried to calculate across this magic date (03:14:07 UTC on 19 January 2038).  date -d "20380119"  date: parsed number part: today/this/now date: input timezone: +01:00 (set from system default) date: warning: using midnight as starting time: 00:00:00 date: starting date/time: '(Y-M-D) 2038-01-19 00:00:00 TZ=+01:00' date: '(Y-M-D) 2038-01-19 00:00:00 TZ=+01:00' = 2147468400 epoch-seconds date: output timezone: +01:00 (set from system default) date: final: 2147468400.000000000 (epoch-seconds) date: final: (Y-M-D) 2038-01-18 23:00:00 (UTC0) date: final: (Y-M-D) 2038-01-19 00:00:00 (output timezone TZ=+01:00) Tue Jan 19 00:00:00 CET 2038   date -d "20380119 + 1 days"  date: parsed hybrid part: +1 day(s) date: input timezone: +01:00 (set from system default) date: warning: using midnight as starting time: 00:00:00 date: starting date/time: '(Y-M-D) 2038-01-19 00:00:00 TZ=+01:00' date: warning: when adding relative days, it is recommended to specify 12:00pm date: error: adding relative date resulted in an invalid date: '(Y-M-D) 2038-01-20 00:00:00 TZ=+01:00' date: invalid date '20380119 + 1 days'   date -d "20380120" --debug  date: parsed number part: today/this/now date: input timezone: +01:00 (set from system default) date: warning: using midnight as starting time: 00:00:00 date: error: invalid date/time value: date:     user provided time: '(Y-M-D) 2038-01-20 00:00:00 TZ=+01:00' date:        normalized time: '(Y-M-D) 2038-01-20 00:00:00 TZ=+01:00' date:  date:      possible reasons: date:        numeric values overflow; date:        missing timezone date: invalid date '20380120'   Is there any way to make GNU date calculate across this date? (on a LINUX 32 bit system)    Operating System: Debian GNU/Linux buster/sid             Kernel: Linux 4.12.0-2-686-pae       Architecture: x86
1023
I've seen this in a few   function fn() {     return +new Date; }   And I can see that it is returning a timestamp rather than a date object, but I can't find any documentation on what the plus sign is doing.  Can anyone explain?
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
122501
The following code returns the time of the current date:  System.debug('Current date: ' + Date.today().toStartOfMonth());   Output:     2018-08-01 00:00:00   How to remove time from date?
18574
I'm trying to convert a date string into an age.  The string is like: "Mon, 17 Nov 2008 01:45:32 +0200" and I need to work out how many days old it is.  I have sucessfully converted the date using:  &gt;&gt;&gt; time.strptime("Mon, 17 Nov 2008 01:45:32 +0200","%a, %d %b %Y %H:%M:%S +0200") (2008, 11, 17, 1, 45, 32, 0, 322, -1)   For some reason %z gives me an error for the +0200 but it doesn't matter that much.  I can get the current time using:  &gt;&gt;&gt; time.localtime() (2009, 2, 3, 19, 55, 32, 1, 34, 0)   but how can I subtract one from the other without going though each item in the list and doing it manually?
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!
3855
I need a method for adding "business days" in PHP. For example, Friday 12/5 + 3 business days = Wednesday 12/10.  At a minimum I need the code to understand weekends, but ideally it should account for US federal holidays as well. I'm sure I could come up with a solution by brute force if necessary, but I'm hoping there's a more elegant approach out there. Anyone?  Thanks.
99127
Is there a function or method to give the last day of a month? For example if the date is 27 feb 2013, the last date should be 28 feb 2013 , it become 29 if its a leap year. if the date was 2 jan then it should return 31 Jan.  If there is no function then any ideas on how we can get this?  Thanks
10999
I am using wordpress 3.2 and I did a query post like this:  &lt;?php query_posts("posts_per_page=1post=type&amp;page=post_parent=10");?&gt;   Then I try to echo out the date of this post I queried like this.  &lt;?php echo the_date(); ?&gt;   It gives me the title of the post and the excerpt and the permalink but no date. What do you think the problem is. I'm sure it's something quite embarrassing.  Here is the code in my template file for the video page:      &lt;?php query_posts("posts_per_page=1post=type&amp;page=post_parent=10");?&gt;     &lt;h2&gt;Recent Video&lt;/h2&gt;     &lt;h3 class="date"&gt;&lt;?php echo the_date(); ?&gt;&lt;/h3&gt;     &lt;p&gt;&lt;strong&gt;&lt;?php echo the_title(); ?&gt;&lt;/strong&gt;&lt;?php echo the_excerpt(); ?&gt;&lt;/p&gt;     &lt;p&gt;&lt;a href="&lt;?php echo the_permalink(); ?&gt;" class="more2"&gt;Watch Now&lt;/a&gt;&lt;/p&gt;   Here I try to put the query in a loop:  &lt;?php query_posts("posts_per_page=1post=type&amp;page=post_parent=10");?&gt; &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;h2&gt;Recent Video&lt;/h2&gt; &lt;h3 class="date"&gt;&lt;?php echo the_date(); ?&gt;&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;&lt;?php echo the_title(); ?&gt;&lt;/strong&gt;&lt;?php echo the_excerpt(); ?&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="&lt;?php echo the_permalink(); ?&gt;" class="more2"&gt;Watch Now&lt;/a&gt;&lt;/p&gt; &lt;?php endwhile; else: ?&gt; &lt;p&gt;&lt;?php _e('Sorry, no posts matched your criteria.'); ?&gt;&lt;/p&gt; &lt;?php endif; ?&gt;   the_date() did not work but the the_title() and other functions worked. By the way this changed my query to the_post() which is not what I'm wanting. I want to query the latest video like I did above the loop.  By the way I used the_date function earlier in the page and it worked. Could that be the problem? Here is it before the code that I had a problem with.             &lt;div id="col75" class="firstcol"&gt;     &lt;iframe id="video" src="http://www.youtube.com/embed/videoseries?list=&lt;?php print get_post_meta($post-&gt;ID,"playlist_id", true); ?&gt;" width='560' height='350' frameborder="0"&gt;&lt;/iframe&gt;     &lt;div id="col25"&gt;         &lt;h2&gt;&lt;?php echo get_post_meta($post-&gt;ID,"speaker", true); ?&gt;&lt;/h2&gt;         &lt;h3 class="date"&gt;&lt;?php echo the_date(); ?&gt;&lt;/h3&gt;