Reputation: 15269
How can I easy convert a unix time to a weeks, days or months?
For example I got 604800
in unix time, which means thats 1 week, 3600
is 1 day etc.
I know this can be done using divisions, but I wonder if there is any ready-function for this.
Upvotes: 0
Views: 1458
Reputation: 1799
From a timestamp, you can get much information using date(). For example:
$year = date('Y', $timestamp);
$dayOfYear = date('z', $timestamp);
$weekOfYear = date('W', $timestamp);
Upvotes: 3
Reputation: 9432
If you are trying to convert seconds to a week number and so on use date() function
Upvotes: 0
Reputation: 10074
CakePHP have nice implementation of this, look at http://api13.cakephp.org/view_source/time-helper/#line-463
Upvotes: 0