Page 1 of 1

Tomorrows Date?

Posted: Wed Oct 27, 2010 9:37 am
by simonjk
Hi,

I am trying to show tomorrows date, using the date picked up from a file.

I can show the date and time the file was created as per below:

Code: Select all

$today = 'sbFCS12.csv'; 
if (file_exists($today)) { 
echo "File updated at: " . date ("D d	 F Y H:i", filemtime($today));} 


But cannot get tomorrows date to show using: 

$tomorrow = 'sbFCS12.csv'; 
if (file_exists($tomorrow)) { 
echo "File updated at: " . date ("d")+1, filemtime($tomorrow));} 
Can anyone help?

Thanks,
Simon

Re: Tomorrows Date?

Posted: Wed Oct 27, 2010 10:12 am
by phppro62
hi mate
I'll give you the tip and you will carry on

$today= date("d") ;
$tomorrow=$today+1 ;
echo $tomorrow ;

Re: Tomorrows Date?

Posted: Wed Oct 27, 2010 10:15 am
by VladSun

Code: Select all

strtotime('tomorrow')

Re: Tomorrows Date?

Posted: Wed Oct 27, 2010 10:56 am
by phppro62
YES you can use the function strtotime() but it will give you along number
To use it practically you should put it in a function
you cn try this

Code: Select all

<?php
 
function d_of_tomorrow($date)
{
    if(preg_match('/([012]?[0-9]?:[0-5]{1}\d\s*[aA|pP]?[mM]?)(\s+)(.+)/', $date, $matches))
    {
        return strtotime($matches[3] . $matches[2] . $matches[1]);
    }
    return strtotime($date);
}
echo date('Y-m-d ', d_of_tomorrow('tomorrow ')); // 2010-10-28 

?>


Re: Tomorrows Date?

Posted: Wed Oct 27, 2010 12:07 pm
by Eran
In your first use (today) you put the timestamp inside the date() function to format it. You should be doing the same for 'tommorow', only you need to increment the timestamp in seconds.

Code: Select all

date ("D d F Y H:i", filemtime($tomorrow) + 3600 * 24);

Re: Tomorrows Date?

Posted: Thu Oct 28, 2010 3:14 am
by klevis miho
First use this function to set the timezone(because the server may have a different timezone than yours):
bool date_default_timezone_set ( string $timezone_identifier )

Then:
$tomorrow = date ("D d F Y H:i", time() + 84600);