Author Topic: Function to Get the Next Date  (Read 378 times)

0 Members and 1 Guest are viewing this topic.

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Function to Get the Next Date
« on: April 21, 2008, 11:51:27 AM »
Is there any function or trick in php or mysql to get the next date when you enter a date.

Input = 2008-04-21
Return = 2008-04-22

Should work for all dates/years. like -

Last day of the Month, Last Day of the Year, Leap Years ?

Is there any direct function to this or would have have to code this calander totally ?

Offline micah1701

  • Devotee
  • Posts: 946
  • Gender: Male
    • View Profile
    • I'm on Google+
Re: Function to Get the Next Date
« Reply #1 on: April 21, 2008, 12:00:40 PM »
$nextDate = date("Y-m-d",strtotime(+1 days, "2008-04-21"));

/edit, "or something like that"
« Last Edit: April 21, 2008, 12:03:28 PM by micah1701 »
"Confidence in the face of risk."

Offline thebadbad

  • Addict
  • Posts: 1,610
  • Gender: Male
  • $me = str_replace($question, $answer, $post);
    • View Profile
Re: Function to Get the Next Date
« Reply #2 on: April 21, 2008, 12:01:47 PM »
Code: [Select]
<?php
$input 
'2008-04-21';
$output date('Y-m-d'strtotime($input.' +1 day'));
echo 
$output;
//2008-04-22
?>

Offline ZypheringTopic starter

  • Irregular
  • Posts: 18
    • View Profile
Re: Function to Get the Next Date
« Reply #3 on: April 21, 2008, 12:43:21 PM »
Code: [Select]
<?php
$input 
'2008-04-21';
$output date('Y-m-d'strtotime($input.' +1 day'));
echo 
$output;
//2008-04-22
?>

Thanks man that worked