Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find month no,name from week number using php

Tags:

php

How to find month no,name from week number using php

like image 899
irshad Avatar asked Nov 23 '25 09:11

irshad


2 Answers

If you have the ISO week number, then to get the month (of the start of the week) you can use strtotime like:

// F = full name of month, n = month number without leading zero
echo date('F n', strtotime('2010-W50'));

Bear in mind that the ISO week might not be the same as your meaning of week, so read on.

If you want to count the whole weeks since January 1st of this year (regardless of what day of the week that is) then you could do as Adnan mentioned:

echo date('F n', strtotime('1 Jan + 50 weeks'));
like image 106
salathe Avatar answered Nov 24 '25 22:11

salathe


echo date('F',strtotime('1 January 2010 +50 weeks'));

www.php.net/date
www.php.net/strtotime

like image 22
acm Avatar answered Nov 24 '25 23:11

acm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!