Calculating Dates (strtotime())

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
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Calculating Dates (strtotime())

Post by kendall »

Hello,

the following is code that i use to check if today's date is greater than 2 months ago from a specified date

Code: Select all

<?php if(mktime(0,0,0,date('m'),1,date('y')) >= strtotime($acc_info['ExpireDate'])-strtotime('-2 months')){ // if expiry date is due in 2 months time ?>

i was looking up inpuit formats for the strtotime however i notice nuthing on using months...

would this yield correct results?
strtotime('-2 months')
i get a timestamp but i am unsure if it is correct or not...just wondering
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

According to GNU tar manual [ http://www.gnu.org/software/tar/manual/ ... tar_7.html ] (which date formats strtotime resembles) `months` is allowed relative item.
Post Reply