note 129941 added to function.strftime

From: Date: Mon, 06 Jan 2025 07:51:32 +0000
Subject: note 129941 added to function.strftime
Groups: php.notes 
Request: Send a blank email to php-notes+get-221754@lists.php.net to get a copy of this message
Year is being displayed wrongly. It is displaying 2025 instead of 2024 E.g. strftime("%G-%B-%d %H:%M:%S", strtotime(date('2024-12-30 10:10:10'))); Output: 2025-December-30 10:10:10 Here G represents 4-digit year corresponding to the ISO week number. Based on this ISO week number year value will be displayed Here B represents full month name Here d represents day of the month (01 to 31) Now because of this %G value we are getting the issue as ISO week number is calculated wrongly. For example, If 30th December is falling on Monday, Tuesday, or Wednesday it is in W01 of the next year. If it is on a Thursday, it is in W53 of the year just ending. If on a Friday it is in W52 of the year just ending in common years and W53 in leap years. If on a Saturday or Sunday, it is in W52 of the year just ending. In this way week calculation happens and as 30th falls on Monday it is taking as W01 of the next year and it displays wrong year output. For previous year no issue for this error because 30 and 31st Dec falls on sat or Sunday . This same error occurs even if the Jan 1st falls on Friday. Then it will calculate it as W53 and displays the previous year value instead of current year. ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 24.206.108.37) ---- Manual Page -- https://php.net/manual/en/function.strftime.php Edit -- https://main.php.net/note/edit/129941 Del: integrated -- https://main.php.net/note/delete/129941/integrated Del: useless -- https://main.php.net/note/delete/129941/useless Del: bad code -- https://main.php.net/note/delete/129941/bad+code Del: spam -- https://main.php.net/note/delete/129941/spam Del: non-english -- https://main.php.net/note/delete/129941/non-english Del: in docs -- https://main.php.net/note/delete/129941/in+docs Del: other reasons-- https://main.php.net/note/delete/129941 Reject -- https://main.php.net/note/reject/129941 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221754) next »