note 92163 modified in function.strtotime by danbrown

From: Date: Sun, 12 Jul 2009 15:12:08 +0000
Subject: note 92163 modified in function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158204@lists.php.net to get a copy of this message
A great little function to see if dates chosen are more than three months apart and if they are, change the end date to three months from the begin date. This is easy to change. <?php function daysDifference($endDate, $startDate) { $startTS = strtotime($startDate); $endTS = strtotime($endDate); $maxTS = strtotime($startDate.' + 3 months'); if($endTS > $maxTS) { $endTS = $maxTS; } $endDate = date('Y-m-d', $endTS); return $endDate; } ?> --was-- A great little function to see if dates chosen are more than three months apart and if they are, change the end date to three months from the begin date. This is easy to change. function daysDifference($endDate, $startDate) { $startTS = strtotime($startDate); $endTS = strtotime($endDate); $maxTS = strtotime($startDate.' + 3 months'); if($endTS > $maxTS) { $endTS = $maxTS; } $endDate = date('Y-m-d', $endTS); return $endDate; } http://php.net/manual/en/function.strtotime.php

« previous php.notes (#158204) next »