SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: server time

  1. #1
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    server time

    I am making a simple php base intranet site.
    where i need to log the time but there is some problem with that it is not accurate.

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How inaccurate?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the machine you have chosen as your server cannot keep accurate time then you have more serious problems than the logs having the wrong time. Get a new machine. Now.

    If it has the wrong time zone, take a look at http://us3.php.net/manual/en/functio...mezone-set.php

  4. #4
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [php]function formatDate($date)
    {
    $str = strtotime ($date);
    //$req = date ("h:i A | M d, Y", $str);
    $req = date ("M d <br> h:i A", $str);
    return $req;
    }
    [php]

    I am using this function to convert the date and time is there any problem.

  5. #5
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and i use
    date("Y-m-d h:i:s");
    to store the data in database

  6. #6
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am using this in windows Operating system with WAMP5 Version 1.7.0

  7. #7
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You still haven't explained what your problem actually is.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  8. #8
    SitePoint Guru Dijup's Avatar
    Join Date
    Jun 2006
    Location
    Kathmandu, Nepal
    Posts
    790
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when i store the time it store in formate 2008-05-19 02:44:56 but when i pull this data it is unable to find Am or PM

  9. #9
    SitePoint Zealot
    Join Date
    Dec 2006
    Location
    England, UK
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dijup View Post
    PHP Code:
    function formatDate($date)
    {
    $str strtotime ($date);
    //$req = date ("h:i A | M d, Y", $str);
    $req date ("M d <br> h:i A"$str);
    return 
    $req;

    I am using this function to convert the date and time is there any problem.
    Try using a capital H instead of the lowercase h :
    PHP Code:
    $req date ("M d <br> h:i A"$str);
    // should be ...
    $req date ("M d <br> H:i A"$str); 
    This will give you the hour in 24-hour format of an hour with leading zeros (00 through 23)
    http://uk3.php.net/manual/en/function.date.php


    Regards,
    Kwah


    PS, you need to close the [php][/php] tags by putting a / in the closing tag - I have edited my quote for you.


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
  •