Jump to content

[SOLVED] date calclation


bhavin_85

Recommended Posts

hey guys

 

ive had a little search but couldnt find anything

 

i need to do the following calculation:

if the date of the last order is less then 3 months ago from todays date return true else return false

i know i need an if statement, but how do u do the actualy calculation?

 

 

Link to comment
https://forums.phpfreaks.com/topic/47252-solved-date-calclation/
Share on other sites

Use the strtotime() function to get the date of three months ago in a UNIX time stamp and the order date in a UNIX time stamp and then compare the two.

 

<?php
$order_date = strtotime('2007-03-14');
$three_months_ago = strtotime('-3 months');
if ($order_date < $three_months_ago) {
//
//  old
//
} else {
//
// new
//
}
?>

 

Ken

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.