开发者

time_since() php function

开发者_运维百科

do i need to include something to use time_since() function in php 5 or is has it been replace?


It doesn't look like that function ever existed in PHP. Do you mean time() ?

However, you can get the time since an event like so...

$timeSince = time() - strtodate('last Saturday');

You can also use the object DateTime.

$now = new DateTime();

$timeSince = $now->diff(new DateTime('last Saturday'), TRUE);

Note that diff() method wasn't introduced until PHP 5.3.


PHP working out time since the post

If you're using PHP 5.3 or newer, you can take advantage of the new Date and Time classes added to PHP.

Specifically, DateTime has a diff method that returns a DateInterval class, which you can then format.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜