SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post is it possible to get the System date ?

    Hi, i tried this function
    Code:
    $date = date('m/d/Y h:i:s a');
    but it is difference in the date of my PC...how can i get the system date of my PC.


    THank you in advance.

  2. #2
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,387
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    Is your PHP code running on your PC, or from a server?

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    Is your PHP code running on your PC, or from a server?
    Hi fretburner thank you for the reply,...running from my PC

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,105
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    PHP only gives the time of your server. You need JS to get the time of the user's computer. E.g.

    http://www.javascriptkit.com/script/cutindex1.shtml
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  5. #5
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,387
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    If you want to make sure that your local server (on your PC) is displaying the right time, check that you have the correct timezone set for PHP.

    You can change the global default for your system in your php.ini file (look for ), or you can set in on a per-script basis with the date_default_timezone_set function:
    PHP Code:
    // Example
    date_default_timezone_set('Europe/London'); 
    You can check PHP's list of supported timezones to find the correct setting for your location.

  6. #6
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi ralph, thank you for the reply,Okay so i cannot get the time of pc if i use the date function...Okay i will try this thank you for this

  7. #7
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    If you want to make sure that your local server (on your PC) is displaying the right time, check that you have the correct timezone set for PHP.

    You can change the global default for your system in your php.ini file (look for ), or you can set in on a per-script basis with the date_default_timezone_set function:
    PHP Code:
    // Example
    date_default_timezone_set('Europe/London'); 
    You can check PHP's list of supported timezones to find the correct setting for your location.
    Hi fretburner, Okay i will try this thank you again.

  8. #8
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,087
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fretburner View Post
    If you want to make sure that your local server (on your PC) is displaying the right time, check that you have the correct timezone set for PHP.

    You can change the global default for your system in your php.ini file (look for ), or you can set in on a per-script basis with the date_default_timezone_set function:
    PHP Code:
    // Example
    date_default_timezone_set('Europe/London'); 
    You can check PHP's list of supported timezones to find the correct setting for your location.

    Hi fretburner, Thank you so much for helping me..it's working it coincide now to my PC...

  9. #9
    SitePoint Member
    Join Date
    Jul 2013
    Location
    Nagpur
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    Try this code
    date_default_timezone_set('Europe/London');
    echo date('m/d/y h:i a', time());


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
  •