Would this date compare code work?

Joined
Nov 8, 2017
Messages
35
Reaction score
11
Thanks guys



Code:
$lastmod=strtotime($lastmod);


$today = date("Y-m-d"); 

if ($today < $lastmod+strtotime('+7 days')) {exit; }

//$lastmod is already in the y-m-d format so I didn't think I needed to add that

Rick
 
Thanks guys



Code:
$lastmod=strtotime($lastmod);


$today = date("Y-m-d");

if ($today < $lastmod+strtotime('+7 days')) {exit; }

//$lastmod is already in the y-m-d format so I didn't think I needed to add that

Rick
Nopes because your $today will return something like "2018-08-30" where as your $lastmod + strtotime("+7 days") will return a ten digit integer like 1234567890. They are not comparable.

Also, $lastmod isn't really in Y-m-d format like you have commented.

Edit: You could compare them like e.g.
Code:
if (strtotime($today) < ($lastmod+strtotime('+7 days'))) {exit; }

Edit 2: Just noticed your occupation. Do yourself a favor, please do not call yourself a developer yet.
 
Last edited:
Back
Top