note 123395 added to intldateformatter.format

From: Date: Mon, 03 Dec 2018 05:08:49 +0000
Subject: note 123395 added to intldateformatter.format
Groups: php.notes 
Request: Send a blank email to php-notes+get-209843@lists.php.net to get a copy of this message
Hello, I am getting wrong date after format for Last day of year. Please check below code <?php $input = '2018-12-31'; $zone = new \DateTimeZone('Asia/Calcutta'); $date1 = new \DateTime($input, $zone); $timezone1 = $date1->getTimezone(); $fmt = new \IntlDateFormatter( 'en_US', 0, 0, $timezone1, NULL, 'M/d/Y' ); echo 'First Formatted output with pattern is ' . $fmt->format($date1); ?> // OUTPUT First Formatted output with pattern is 12/31/2019 <?php $input = '2018-12-31'; $zone = new \DateTimeZone('Asia/Calcutta'); $date1 = new \DateTime($input, $zone); $timezone1 = $date1->getTimezone(); $fmt = new \IntlDateFormatter( 'en_US', 0, 0, $timezone1, NULL, 'M/d/Y' ); echo 'First Formatted output with pattern is ' . $fmt->format($date1); ?> // OUTPUT First Formatted output with pattern is 12/31/2018 Thanks Nirav Patel ---- Server IP: 208.43.231.9 Probable Submitter: 202.131.115.180 ---- Manual Page -- http://php.net/manual/en/intldateformatter.format.php Edit -- https://master.php.net/note/edit/123395 Del: integrated -- https://master.php.net/note/delete/123395/integrated Del: useless -- https://master.php.net/note/delete/123395/useless Del: bad code -- https://master.php.net/note/delete/123395/bad+code Del: spam -- https://master.php.net/note/delete/123395/spam Del: non-english -- https://master.php.net/note/delete/123395/non-english Del: in docs -- https://master.php.net/note/delete/123395/in+docs Del: other reasons-- https://master.php.net/note/delete/123395 Reject -- https://master.php.net/note/reject/123395 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209843) next »