Hello everybody, I'm a PHP newbie and have the following situation:
I'm preparing a site for a night club in my city and want to provide the user with the option to book his seat online. For this procedure, I'm going to have to write a simple HTML form connected with a PHP script on my server, which will be doing INSERTs 99% of the time. However, in order to avoid last-minute confusion, I would like to freeze reservations that are submitted too late, for example, three hours or sooner before doors open. If that particular time of the day (i.e: the time when I want to freeze reservations) is 8pm (20:00) and my timezone is GMT + 2, then how am I supposed to code this condition in my PHP?
All that is needed is that an informative message be printed on the user's viewport, stating the inability to book seats as late as he or she attempted to.
Thank you for your time.
Note: I mentioned my time zone because the server I'm hosting my PHP script on is American (Texas, I believe), and the club is Greek. We're talking about diametrically opposed timezones.
Time - dependent PHP code
Moderator: General Moderators
Re: Time - dependent PHP code
Here's an example for converting to other timezones.
Here's a list of supported Timezone strings in Europe:
http://us3.php.net/manual/en/timezones.europe.php
You can build your time string with date() function http://www.php.net/manual/en/function.date.php
with your selected timezone in whatever format your database is in, then compare the time strings in your query for valid time ranges for your reservations.
Code: Select all
date_default_timezone_set('Europe/Malta');
$today = date("D M j G:i:s T Y");
echo "<br />".$today."<br />";http://us3.php.net/manual/en/timezones.europe.php
You can build your time string with date() function http://www.php.net/manual/en/function.date.php
with your selected timezone in whatever format your database is in, then compare the time strings in your query for valid time ranges for your reservations.