Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Php Datetime

  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php Datetime

    For some reason, it's always 1 hour ahead.
    if now my windows clock shows 1AM, it will output 2AM.
    The problem is, i am using a JS countdown in my website...
    I get the current time using JS and it works fine but then i need to use
    PHP datetime to get the current date and to add a submitted number of minutes .
    I can't do that because when i get the current time with PHP, it's 1 hour ahead.

    what's the problem?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    If your site is not hosted on your computer the server likely has a different timezone than you. JS retrieves the timezone from your computer while PHP retrieves it from the server. There are a number of functions for manipulating the date/time, but make sure you have the version of PHP that is required or newer.
    Last edited by Inigoesdr; 08-17-2007 at 11:59 PM.

  • #3
    New Coder
    Join Date
    Apr 2007
    Location
    India
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sysdate() function

    Hi,

    use the sysdate() function to have the current date
    GemGuy

    Be friend of me
    Hey what a fun

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    That's not a real function...

  • #5
    New Coder
    Join Date
    Jul 2006
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    If your site is not hosted on your computer the server likely has a different timezone than you. JS retrieves the timezone from your computer while PHP retrieves it from the server. There are a number of functions for manipulating the date/time, but make sure you have the version of PHP that is required or newer.
    man, it's hosted on my own computer and no matter what time i put, it will
    always be 1 hour ahead while JS gets the right timing.

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Excellent. So check your date.timezone setting in php.ini, and/or use a function to tell you what the current setting is or change it. Or use something like this to get the timestamp: $timestamp = time() + (60 * 60);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •