SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: date("U")?

  1. #1
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date("U")?

    I was juts wondering exactly what this is...

    Thanks,
    ~someonewhois

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It gives the number of seconds since the epoch. I'm not fully clued up on this, but it is some date in the past that UNIX dates are based on, or something like that

    [edit]Here is some more info:
    http://www.linuxplanet.com/linuxplanet/tutorials/215/1/

    Sean
    Last edited by seanf; May 9, 2002 at 13:39.
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    /me thinks that was copied from the php manual!

    I see...

    I got this code from a friend for flood control, and it uses that date. If you take it from like 5 minutes ago, in a database, and you subtract if with the now ("U"), it'll give you 1 for soem reason.

    I will chagne it to something mroe specific..

    Thanks,
    ~someonewhois

  4. #4
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a trick you could use is assign a variable at the top of the page...
    PHP Code:
    $nowtime now("U");
    $phpdate date("U"); 
    Then you could just use the variables....just a time saving idea.

    Sketch
    Aaron Brazell
    Technosailor



  5. #5
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Errm...

    I tried that...

    Fatal error: Call to undefined function: now()

  6. #6
    SitePoint Addict AbelaJohnB's Avatar
    Join Date
    Oct 2001
    Location
    Eureka, CA. USA
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Sketch
    PHP Code:
    $nowtime now("U");
    $phpdate date("U"); 
    Sketch

    /me thinks Sketch mistook MySQL for PHP <smile>



    now() is a MySQL date-tag, and has nothing to do with PHP, per-sae.




    PHP Code:
    date('U'); 
    is simply a method of acquiring the date/time stamp in UNIX format.


    There are still a fair amount of programers who still use the UNIX-Format, for dates within their scripts.

    Others use GMT, and others use the SQL method of xxxx-xx-xx xxxx


    Which one you use, AFAI'm concerned, is which one you like the best. Many, many, people will tell you 'xyz' is the best, but I've never seen anything to really prove one method is better than the other.

    The only problem I've ever encountered using Unix-format, is that it doesn't handle dates 50+ years ago. So, if you are have a field where people enter their age, and you have a bunch of old'folk, the datestamp will not work correctly. I cannot comment on GMT method, never used it. The normal SQL method is really good if you are a SQL fan.

    Anyway, these are just my own thoughts and opinions.
    John B. Abela
    www.JohnAbela.Com

  7. #7
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see, thank you!

    I kinda figured somethign liek that!

    Thanks,
    ~someonewhois

  8. #8
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW, date('U') is exactly the same as time(), no?
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  9. #9
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    www.php.net/date has a list of all the letters used for time.
    - the lid is off the maple syrup again!

  10. #10
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by notepad_coder
    www.php.net/date has a list of all the letters used for time.
    is this in reply to me? i'm aware of all the letters used in date(). i'm saying that date('U') is, according to the page you linked

    U - seconds since the epoch
    this is exactly the same as time()'s output, is it not? run this

    PHP Code:
    echo date('U'), '<br />'time(); 
    and they should both be the same, proving my point.


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
  •