Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Modifiying date() function

date php

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 jasonalien

jasonalien

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 194 posts

Posted 01 April 2013 - 07:19 AM

Hi, I am using

 

$question_time = date("d-m-Y H:i:s"); 
 

 

code in my PHP file. It works but it works 7 hours late. If it is 8:00 pm in my time it shows 1:00 pm.

I tried

 

date("d-m-Y (H + 7):i:s");
 

 

but it didn't work. How can I fix this problem?

Thanks



#2 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts

Posted 01 April 2013 - 08:46 AM

Your default timezone is probably set to GMT. Try checking the documentation page for the date() function for the proper format specifiers for timezone specification. Alternatively, you could try calling date_default_timezone_set() before calling your date() function to set the proper timezone.

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3 jasonalien

jasonalien

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 194 posts

Posted 03 April 2013 - 03:45 AM

Thank you, that helped a lot!






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download