SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    PHP Date and Computer Date

    Hai,

    My php script and my computer date are diffrent.
    alwas shows one day behined. may be i am in asia and the webserver which has php installed is in the US.

    example. My computer shows October 9 now an php prints October 8.

    Now how i do tell the php script to show the date and time in my computer ?

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Umm that location of the hosting server really matters on date time. You need to work with GMT or you need to set the environment variable to set the local time zone and also you must know the string that is required to set the timezone of a location.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks raj, can i set the time zone in my hosting server some ware? can i edit the php ini ? please give some advice. i have hosted in GoDaDDY.

  4. #4
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No no. It is not set in ini. You need to set timezone in your running page like this:
    Code php:
    $string = "Asia/Katmandu";
    putenv("TZ=$string");
    echo date('Y-m-d H:i:s');

    Set this putenv("TZ=$string"); in your each file's top then use your date function get the time.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  5. #5
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks rajug,
    ill check it

  6. #6
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    960
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Rajug, Problem Solved !!!

    Thanks for the help dear. Really appricited.


Bookmarks

Posting Permissions

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