0

With PHP date functions, we can easily use a week number which change 0 to 53. This count starts from zero each year.

I'm looking for a date format which give me a numeric value which is continuing each year without count reset.

Example:

this_week = 578 (this week is in 2015)
newt_week must be = 579 (even it's in next year)

Is there any pre-defined format for that purpose? If not, which approach can help me to find a custom solution?

2
  • When would this start? 2000?
    – JBithell
    Dec 31, 2015 at 9:46
  • I've got an idea, if we start counting in seconds from say, erm, 1st jan 1970 and use that as a standard count then count the weeks that way
    – Billy
    Dec 31, 2015 at 9:54

1 Answer 1

1

I would suggest using the PHP time function to convert to UNIX time (seconds since 1970-01-01). You can find the number of weeks since a given date by dividing by number of seconds in a week. In fact, the PHP documentation documentation (http://php.net/manual/en/function.time.php) shows an example very much like what you are trying to achieve.

1
  • You can find the number of weeks since a given date by dividing by number of seconds in a week. What is with daylight saving time, leap years, leap seconds?
    – hek2mgl
    Dec 31, 2015 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.