Eureka Moment Wiki

One eureka moment at the time

User Tools

Site Tools


development:php:date

PHP datetime

$EndDate = date_create(%MYSQL DATETIME FORMAT%);
date_add($EndDate,new DateInterval('P7D')); //Add 7 days
$Now = date_create(date('Y-m-d H:i:s'));
//$DiffDate = date_diff($Now,$EndDate); //Returns larger-than-zero integer
//echo $DiffDate->format('%d');
if ($EndDate>$Now) {
    $Larger=true;
} else {
    $Larger=false;
}

Discussion

Enter your comment:
Y P W K U
 
development/php/date.txt · Last modified: 2019/10/31 09:04 (external edit)