I'm trying to get a number in a database to reset at the beginning of each year, and this is not the easiest thing to test so I'd like to know if this would work. I have two times the first is $db_time which is some time in the past that the database has been accessed. The second is $realtime which assumes the value from time(). What I want to do is see if $db_time and $realtime are in different years. What I have right now is
if(strftime("%Y",$db_time)-strftime("%Y",$realtime))
{
$query = "UPDATE tinfo SET id=1";
update($query);
}
I think maybe it should be
if(intval(strftime("%Y",$db_time))-intval(strftime("%Y",$realtime)))
{
$query = "UPDATE tinfo SET id=1";
update($query);
}
But I'm not sure. Does anyone have any advice? Thanks a bunch.