Date "W" offset option

I have a timesheet system which is like a calendar and used to work but now the client needs the starting date to be on a tuesday instead of a monday.

The basic code is as follows:


// ORIGINAL YYYY-MM-DD
$datex = explode("-",$timesheet["Timesheet"]['date']);

$oldts = mktime(0,0,0,$datex[1],$datex[2],$datex[0]);

$week=date("W",$oldts);


How would I go about changing this so it thinks the tuesday is the start of the week and monday is the last day of the week.

Thankyou

If date($oldts,‘w’) == 1, $week–;

Sometimes it’s not a question of making the function do what you want, but working with what it gives you :wink:

PS: You could also have gotten $oldts by doing a [FPHP]strtotime[/FPHP] on the original date - strtotime takes Y-m-d as valid input.

Thanks, it didn’t seem to change anything. I changed it as follows though:

 if (date("W", $oldts) == 1) { $week--; } 

I thought it might have to do with the timestamp, changing that back one day or similar.

You got the wrong w. look closer. (w = day of week. W = week of year)

Thankyou, that changed some of the weeks around. Do you mind telling me which $week-- is doing or where I can look into it further to understand?

Thanks

– is “decrease by one”

Thankyou for your help!