Jump to content

Use PHP to echo YYYYMMDDHHMMSS and GMT times


damien275x

Recommended Posts

Hello PHP Freaks,

 

I am using a basic payment frame system, and it requires me to pass in a GMT time in this format, in a hidden form.

 

"YYYYMMDDHHMMSS"

 

I have found a lot of examples in PHP on how to format the above tag, but what would be the easiest way to generate it as is?

To make things a little more complicated, there are different users in different GMT times, and based on the state they select it needs to + or - hours from the current time to get the GMT time.

 

The formulas to calculate the results are as follows, just after the best approach in PHP to calculate:

 

State #1:  CURRENT_TIME + 10 HOURS = GMT TIME (echo as YYYYMMDDHHMMSS) and assign to $GMT_TIMESTAMP

State #2:    CURRENT TIME + 9.5 HOURS = GMT TIME  (echo as YYYYMMDDHHMMSS) and assign to $GMT_TIMESTAMP

 

 

 

What would be the best way to tackle this ? At the moment I have select boxes where the user can pick the state, then click SUBMIT.

 

Thankyou in advance,

 

D

The time is calculated according to your server. Not according to where the user is. The only way it would be like that is if your code specifically altered the timezone PHP was using to calculate dates.

 

gmdate("YmdHis")

for starters, making sure that the timezone is the server's timezone and not the user's.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.