开发者

PHP convert remaining seconds (from now) into date

Good morning, guys. I was just thinking about the small PHP crawler, that could browse my 2 favourite websites and show me some info about auctions from 1 category. I haven't started to write anything, because I stuck on the remaining time that every auction has. I want to snow only the date, when the auction ends. But these sites provide me only a seconds (or miliseconds), that remains from now to the end. How to convert开发者_StackOverflow these seconds into normal date like 2011-08-24? I appreciate any advice.

George


Just do $date = time() + $seconds;. Now $date holds the date on which the auction will end. You can output that in a nice way with date().


//watch for time zone issues
echo date('l jS \of F Y h:i:s A',time()+$remaining);

+ not - sorry


echo date('Y-m-d',time() - $remaining_seconds);

This will format your date as YYYY-MM-DD as you requested.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜