I have program that allows our will-call customers to pick the date & time they want to pick up their order. However, we require that the time be at least 1 hour ahead to allow time for the order to be processed. I am using a basic HTML5 date/time picker. That part works fine.

Though, I seem to be running in trouble were I check they have selected a future time of an hour ahead. I am using the following to get 1 hour ahead - which is also my question: Is this a safe method to get an hour ahead or is time set by ISP or could it be via the browser and the time on their machine?

$oneHourAhead = date('G:i', strtotime('+1 hour'));

After researching this a bit I think I figured out that setting:

<?php
date_default_timezone_set('America/Chicago');
?>

And going by the customer default location I could validate 1 hour out based on their timezone.

Is marking resolved possible in this new green machine?

    jeepin81 The time in PHP is dependent on the server time and the time zone you selected in your php.ini (unless you adjust it in code). If the server is in a different time zone, you will need to adjust either the client time or the server time (or both) before comparing. Of course, you will need to know your user's timezone to do that.

    Just remember that a database has its own time zone as well. My personal preference is to use GMT for everything.

      Another way of determining the user's timezone (if you do have users that are crossing timezones to pick up their orders) is to have their submission include their current time as well as their requested pickup time. Comparing their current time with yours (rather, your server's configured zone) will give the timezone difference (roughly - their clock may be wrong).

      Or, as ixalmida suggests, do everything in UTC, including the time and date as submitted by the form (JavaScript has methods for getting that, and Date.getTime() is also timezone-independent, being effectively the same thing as a Unix timestamp).

      Needless to say, a form that makes the check itself ("is the requested time more than an hour in the future?") is a nice user convenience.

      Is marking resolved possible in this new green machine?

      I don't see any way to do it. You could edit the thread title if it allows you. (I see a "Rename" option when I click the drop-down arrow on the "Reply" button, but am not sure if that's only for moderators, or if the thread creator can do it, too?)

      dalecosp

      Doesn't seem to allow any tags other than those which are used to essentially classify the sub-forum.

        Write a Reply...