Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the start day of week from 'monday' to 'tuesday' in Php

Tags:

date

php

calendar

Hi friends i need to get the week count .

for ex 1,2,3 .... 52 based on the current year .

In php week starts from Monday or Sunday by default

Is there anyway to set 'Tuesday' has default starting day .

my code is ...

echo "current week of 2012 this year is ..". $weekNumber = date("W");

output for exapmle 16 . whereas correct should be 15 .

because i need the week starting from tuesday not monday , can anyone tell me how to do it .

since there is very less documentation on it will help others in future if answer is found :)

your help and time will be appreciated . or please suggest me a way in comments then :)

like image 538
Rinzler Avatar asked Apr 16 '12 13:04

Rinzler


1 Answers

I got my solution thanks to an answer from ramesh.

To change Tuesday as the start of the week, I did it by using:

echo "Week count : ".date("W", strtotime("- 1 day"));
like image 133
Rinzler Avatar answered Oct 10 '22 06:10

Rinzler