Jump to content


Photo

Time stamps & comparing them


  • Please log in to reply
2 replies to this topic

#1 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 18 August 2006 - 01:22 PM

Hi everyone!

I'm trying to write a script that grabs info from a database where the timestamp of the SQL field is 6 months old or earlier.

Can anyone help? My brain's fried. :o(

cheers,
gerk
Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 18 August 2006 - 01:30 PM

<?php
$timestamp = time()-15768000;
$query = mysql_query("SELECT * FROM whatever WHERE date>='{$timestamp}'");
?>

Try something like that. I'm now sure if that is what you mean.

15768000 = 60*60*24*365/2 - which is a half year (six months).
14515200 = 60*60*24*7*4*6 (six months based on four weeks per month).

#3 gerkintrigg

gerkintrigg
  • Members
  • PipPipPip
  • Magician
  • 828 posts
  • LocationBristol, UK
  • Age:37

Posted 18 August 2006 - 03:13 PM

Yep, thanks very much, that's great
Neil Trigger - http://www.ghostlypublishing.co.uk - Ghostly Publishing - Children's Fantasy Books




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users