Skip to content

Instantly share code, notes, and snippets.

@thierrypigot
Created December 20, 2017 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thierrypigot/b4cb3b4acb40abceccf56103338061ed to your computer and use it in GitHub Desktop.
Save thierrypigot/b4cb3b4acb40abceccf56103338061ed to your computer and use it in GitHub Desktop.
Afficher la page qu'à partir d'une certaine date/heure
<?php
date_default_timezone_set('UTC');
$tz = 'Europe/Paris';
$timestamp = time();
$dt = new DateTime("now", new DateTimeZone($tz)); //first argument "must" be a string
$date = $dt->setTimestamp($timestamp); //adjust the object to correct timestamp
$date = $dt->format('Y-m-d H:i:s');
$date = strtotime( $date );
$date_mel = strtotime( '2017-11-07 20:30:00' );
echo 'Date : '. $date .' / '. date( 'Y-m-d H:i:s', $date ) .'<br>';
echo 'Date MEL : '. $date_mel .' / '. date( 'Y-m-d H:i:s', $date_mel ) .'<br>';
if( $date < $date_mel ){
echo 'Attente';
}else{
echo 'Go!';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment