Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Stupid php date question (new problems!)

3stripe3stripe ✭✭
edited February 2006 in Vanilla 1.0 Help
I just want to print the current time as a 6 digit string, eg 193005... but the code I'm using always seems to be about 10 minutes ahead... what am I doing wrong!?

<?PHP print("time=".date("His")); ?>


  • is this on your local server or remote?
  • 3stripe3stripe ✭✭
    edited January 2006
    maybe my host is in a different (or just wrong) time zone... get the correct time on my own site:
  • yeah.. the servers are just not synchronized - nothing to worry about
  • 3stripe3stripe ✭✭
    edited January 2006
    need the right time for a clock on a flash website.... could it be the host server is set to the wrong time... it's 7.54pm just now but the server time is coming up as 7.05pm... it's not like it's even plus or minus an exact hour... seems a bit strange!?

    you can see the wrong time at the bottom here, in the smaller text:
  • I'd suggest you check with your hosts to check whether the server clock is right. If they wont do anything about it, you then need to see whether it's always +/- X seconds. If it is, just take that number off the timestamp you're using in your date function.
  • will do tomorrow. cheers guys. hometime now :-D
  • Is there a php library for interfacing with time servers?
  • date('His', strtotime('-10 minutes'));
  • heheh, i got to phone my hosts now just to see if they really have got the wrong time on their server! but thanks for the code nick... it's complicated running a flash clock off just this one variable so not sure what i'll do next...
  • lechlech Chicagoland
    Or you could easily use flash to display the correct time based on the clients computer. Then just offset it based on where the server is located.
  • Clock has to show time in New York and Glasgow, that's the bit that causing the problems :-(
  • Is it possible to scrape the data from another site?
  • lechlech Chicagoland
    seems easy enough to do if you simply call utcdate in flash, then just do an offset. simple.
  • Aye! I got it working on GMT time now, just waiting for them to set it to the right time
  • There are many ways to achieve the wanted results, but you could query the for proper time, their servers seem to be always on correct time. Also, there is a timezone value for the date() function, I think Glasgow is in Greenwich Mean Time, there is no offset there, and you can set the other clock by EST with the timezone value.
  • Kosmo, how can I do that in php then? (Please excuse my total duffessness at php, i'm not a programmer ;-)
  • You should read the date() function user contributed notes, there are usually neat tricks there. But you should note to the server that has the clock in wrong time that their clock is out of synch, sice if the whole server is off, all their sites using anykind of date specific scripts are off. You can go and check the absolutely correct time from and download their nifty atomic clock synch program. Just to check how much their clock is off. About checking the for the date, I'm not so sure how, but you can query the time from external sources if the external source allows.
  • 3stripe3stripe ✭✭
    edited January 2006
    Ok next question... I need to pass the php variable $timestamp to a javascript in my page....

    so inside my javascript there would be the line:

    fo.addVariable("thetime", TIMESTAMPGOESHERE);

  • Ok I got it, phew.
This discussion has been closed.