small php time comparison help

Discussion in 'PHP' started by KinetiX, Jan 5, 2010.

  1. #1
    ok so i got an sql that inserts a row in a database and sets a field time with the value:
    time()

    so the field has unix date in it
    for example the value is: 1262736620

    ok what i need to do now is make a script that will delete all rows in that table for wich the insertion date has passed over 15 minutes
    ..i mean..
    to delete all rows wich were inserted 15 or more minutes ago judging by time field
    kinda like time<15 minutes
     
    KinetiX, Jan 5, 2010 IP
  2. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #2
    WHERE time_field < (time()-(60*15))

    time() function is seconds that have passed since 1970-01-01 00:00:00
     
    n3r0x, Jan 5, 2010 IP
  3. JAY6390

    JAY6390 Peon

    Messages:
    918
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I hope when you use the time function here you dont expect it to work directly in MySQL. It will with php but TIME for MySQL extracts a time from a date and time string
     
    JAY6390, Jan 5, 2010 IP
  4. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #4
    Lol ofc i don´t... duh it´s a php function.. but then again just break it out of the statement like '".(time()-(60*15))."' and it does work.. I just showed him the basics of it.. if he doesn´t know how to use php syntax wise he should not be asking about this, he should be reading a "basic syntax" manual
     
    n3r0x, Jan 5, 2010 IP