I have a PHP script to identify the current month and current week within that month.
For today, it should output 501 (i.e. 5th week of the 1st month), however right now it outputs 101.
Can someone explain why this is the case and how I can resolve? I feel I'm missing something obvious.
<?php
date_default_timezone_set("Europe/London");
function weekOfMonthFunction($date) {
$firstOfMonth = date("Y-m-01", strtotime($date));
return intval(date("W", strtotime($date))) - intval(date("W", strtotime($firstOfMonth)));
}
$week = weekOfMonthFunction($date2);
$week = $week + 1;
$month = date("m");
$week_month = $week.$month;
echo $week_month;
question from:
https://stackoverflow.com/questions/65886220/output-current-week-number-within-month-php 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…