How to get the 31st Decemeber while your are in 1st Jan?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rashed
Forum Newbie
Posts: 17
Joined: Fri Jun 06, 2003 6:27 am
Location: Islamabad, Pakistan.

How to get the 31st Decemeber while your are in 1st Jan?

Post by rashed »

Hi

Is there any function to get the previous date?
regards
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you're using timestamps you can easily go back a day:

Code: Select all

$today = mktime(); 
$yesterday = $today - (24*60*60); 
echo 'Yesterday was: '.date('d/m/Y', $yesterday);
Mac
rashed
Forum Newbie
Posts: 17
Joined: Fri Jun 06, 2003 6:27 am
Location: Islamabad, Pakistan.

Post by rashed »

Thank you vey much Mac,
What i did was
if(checkdate ( 12, 31,date("Y")-1 ))
{
//processing
}
But you are genius
rashed
Forum Newbie
Posts: 17
Joined: Fri Jun 06, 2003 6:27 am
Location: Islamabad, Pakistan.

Post by rashed »

The simple code to back-up the previous year's data at the begining of the year. ->
if (!strcmp(date('d/m/Y', $yesterday),"31/12/".(date("Y")-1)))
bk_up();
Post Reply