note 129850 added to datetime.add

From: Date: Tue, 12 Nov 2024 15:53:45 +0000
Subject: note 129850 added to datetime.add
Groups: php.notes 
Request: Send a blank email to php-notes+get-221647@lists.php.net to get a copy of this message
Depending on what your use case is, adding months might or might not give you the correct result. // Prints "2024-03-02" instead of "2024-02-29" print Date::fromString('2024-01-31T10:00:00') ->add(new DateInterval('P1M0D') ->format('Y-m-d'); ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.137 (proxied: 83.23.49.149) ---- Manual Page -- https://php.net/manual/en/datetime.add.php Edit -- https://main.php.net/note/edit/129850 Del: integrated -- https://main.php.net/note/delete/129850/integrated Del: useless -- https://main.php.net/note/delete/129850/useless Del: bad code -- https://main.php.net/note/delete/129850/bad+code Del: spam -- https://main.php.net/note/delete/129850/spam Del: non-english -- https://main.php.net/note/delete/129850/non-english Del: in docs -- https://main.php.net/note/delete/129850/in+docs Del: other reasons-- https://main.php.net/note/delete/129850 Reject -- https://main.php.net/note/reject/129850 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221647) next »