Now, I hope that your page (page1.html is from a rewrite rule or knows to execute the PHP code - HTML will not)
OR
You will need an Ajax request, so you can get the server time while the user is on your “page1.html” page.
Make few requests and check the time then redirect. This is not so simple as the first code but also not so complicated.
OR
You can make a client-side redirect.
<script>
var d = new Date();
if( d.getFullYear() == 2013 && d.getMonth() == 3 && d.getDate() == 21 && ... hour and minute ) {
window.location.href = 'page2.html';
}
<?php
//March 21, 2014 at 18:20 GMT
date_default_timezone_set('GMT');
$target = strtotime("March 21, 2014, 18:20");
$date = strtotime(date("F j, Y, g:i a"));
$page = ($date>=$target ? "page2.html" : "page1.html");
//// $page can be used as you wish. Assuming header location.///
//IMPORTANT: This must be at the top of your page before anything is sent to browser!
header("location: $page");
exit;
?>
Haa, ha Good spot vectorialpx. I suppose you could put this ONLY on page1.html assuming an html page is going to read php in the first place.
<?php
//March 21, 2014 at 18:20 GMT
date_default_timezone_set('GMT');
$target = strtotime("March 21, 2014, 18:20");
$date = strtotime(date("F j, Y, g:i a"));
//IMPORTANT: This must be at the top of your page1.html before anything is sent to browser!
if($date>=$target){
header("location: page2.html");
exit;
}
?>