1

I am trying to display a message for the user once they begin checking out a product past a certain time (10AM).

How would I go about doing this? Is this even possible? I'm just not sure how to catch the time from the user.

1

This can be done with the Javascript Date object. It uses the browser (device) time.

Something like the following would work

<div id="divWithWarningTextId" style="display:none;">It's past 10!</div>

<script type="text/javascript">
var time = new Date();
if (time.getHours() >= 22) {
  document.getElementById('divWithWarningTextId').style.display = 'block';
}
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.