Jump to content

How do I find weeknumber for given date without using mktime (UNIX timestamp)?


Tore

Recommended Posts

Hi.

I would like to be able to find weeknumber and weekdaynumber
without using the UNIX timestamp (e.g use of mktime).

I'm looking for a function that use a date to calculate the above.

The reason I'm asking is that I would like to display calendars further back in time that the UNIX timestamp handles.

Does anyone out there know if there is a custom function somewhere that are able to calculate which weeknumber
a given date is within?

would also appreciate something that also find the
weekdaynumber for a given date, preferably for both using
monday and sunday as the first day of the week?
This could be a usable workaround. If you take my birthday Saturday, Jan 22nd, 1949, and given that the calendar repeats itself exactly every 28 years,

[code]<?php
  $dob = '1949-01-22';
  $yr = substr($dob, 0, 4);
  $tmpyr  = $yr + 28;
  $tmpdob = str_replace($yr, $tmpyr, $dob);
  
  echo "Born on a " . date('l', strtotime($tmpdob)) . " in week #" . date('W', strtotime($tmpdob));
?>[/code]

So basically changing the year from 1949 to 1977 (inside the the 1970 - 2037 unix range).

edit: BTW, this works with PHP5 on Windows :-
[code]<?php
  $dob = '1949-01-22';
  
  echo "Born on a " . date('l', strtotime($dob)) . " in week #" . date('W', strtotime($dob));
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.