Hello Daniweb,
I've searched all over including a few threads here on this topic and it looks like I'm running out of options. I'm developing a travel reservations website with a promotional code field on the payment page. The admin wants to be able to create coupon codes with an expiry date. How do I check the expiry date of the coupon against the user's local time with a server side language like php? My server's timezone is CST but the reservations come form all over the world.

Any ideas on how to get the local time effectively and by reducing fraud as much as possible? (since with javascript, the user could just set their clock back).

Or any other possible way to approach the expiring coupon problem would be appreciated as well.

Recommended Answers

All 6 Replies

There is a quick solution.
If your server is in CST, you can advertise it to end by CST time settings???
Besides, using javascript shouldn't be an issue. If I am in UK and want some more time, I can use a proxy server and get their local time?
So the explanation that user can change javascript cannot be taken in? even server side can corrupted.

Hope it helps. :)

Thanks Bud! You make a good point with the proxies. I suppose there really isn't an absolutely breakable way of doing this. However, my client has ad campaigns (both print and tv) created that have the wording along the lines of "Use promo code BLABLA for a 20% discount. Offer expires Jan 31, 2012". I know if I leave it according to CST, he's sure to get calls from people screaming at him that the coupon says it's expired even though they have bla bla hours remaining. And I don't want to have to explain it to him at that time why it's like that lol

Member Avatar for diafol

I agree with MaxPrime - have the timezone displayed along with the time so that there's no confusion.
You could also have a dropdown with a list of timezones with something like "How much time do I have left?"

It's a relatively trivial thing, for an example of using timezones (my site): http://www.diafol.org/datetime.php

Thanks Gentlemen! But wouldn't having a drop-down to select timezone increase the chance of fraud? I am starting to see however, that there really isn't a solid way of going about this. I'm gonna mark this solved and just try to convince him to forget about specifying the time and just go with a date so atleast it's vague. Most bigger companies do have it like that anyway. No time, just date.

Member Avatar for diafol

I know you've solved this, but to answer the fraud question. No - the offer closes at the server time (CST?). 'Period'

That's nothing to do with what a user sees. If a user sets the page to say GMT (+6 hours on from CST) - you assume that they have 6 hours less, but that isn't the case. You can display a countdown if you like in CST server time - it's the same for every timezone (e.g. hours / mins left).

All I was suggesting was that if you say

Closes at 13:30 CST. That may mean nothing to your average GMT timezoner, so a dropdown to note the time in GMT (as well as others) could be useful - it should show 19:30 if user selects this. I have to be honest, a line saying how much time is left (js countdown??) should suffice, without messing with timezones.

I have set it up to expire at CST time and yes, the advertising will just have CST specified in it from now onwards.

I did dabble with the idea of the counter, but where would you put this counter? I mean, when the customer puts in all their information, they're taken to the payment page, where they see the coupon field along with a "Apply Discount" button before putting in their credit card info. Having multiple coupons, how would I display countdowns for all coupons?

Regardless, I guess I was just over thinking the whole thing. As you guys pointed out, just mentioning CST along with expiration time does seem to the simplest and easiest solution.

Cheers Guys! Thanks for all the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.