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

[eluser]xwero[/eluser]
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?
#12

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

[eluser]xwero[/eluser]
thanks for the information
#14

[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?
#15

[eluser]Thoer[/eluser]
Why don't you let your sql server do this?
#16

[eluser]delay[/eluser]
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.
Code:
$this->load->helper('date');
$unixdate = mysql_to_unix($mysqldate);
then call the timeDiff function from the above link.

Code:
$TimeAgo = $this->timeDiff($unixdate,false, 1, minute);
#17

[eluser]Gordaen[/eluser]
[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