Welcome Guest, Not a member yet? Register   Sign In
relative dates?

I'm not sure if the strtotime function parses the mysql dateformat correct. According to the manual it expects the US english date format. Do you have other experiences?

[eluser]Mark van der Walle[/eluser]
I have been using that often. Just tested it again and it works like a charm Wink

thanks for the information

[eluser]Derek Allard[/eluser]
Well I'll be... Mark, nice tip. PHP.net usernotes warn that this didn't work prior to PHP 5. Can you comment on that?

Why don't you let your sql server do this?

I was just looking at doing something similar. There is a good function that handles this on the php site. http://us.php.net/time Look for the "timeDiff" function. It will do exactly what you want. You can also easily convert your mysql dates into the timestamp formats it needs by loading the date helpers.
$unixdate = mysql_to_unix($mysqldate);
then call the timeDiff function from the above link.

$TimeAgo = $this->timeDiff($unixdate,false, 1, minute);

[quote author="jvittetoe" date="1196845301"]one more thing, how can i convert a mysql timestamp into a unix timestamp.[/quote]

You can do that at the database with MySQL's UNIX_TIMESTAMP() function or else load CI's date helper and use mysql_to_unix().

As far as the discussion about intelligent defaults, I think using the largest two units makes the most sense for defaults, but configurability would be nice.

Theme © iAndrew 2016 - Forum software by © MyBB