note 119260 added to dateinterval.construct

From: Date: Thu, 28 Apr 2016 16:47:25 +0000
Subject: note 119260 added to dateinterval.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-205391@lists.php.net to get a copy of this message
To recover the interval specification string: <?php function get_interval_spec(DateTime $alpha, DateTime $omega) { $intvl = $alpha->diff($omega); $date = NULL; if ($intvl->y) $date .= $intvl->y . 'Y'; if ($intvl->m) $date .= $intvl->m . 'M'; if ($intvl->d) $date .= $intvl->d . 'D'; $time = NULL; if ($intvl->h) $time .= $intvl->h . 'H'; if ($intvl->i) $time .= $intvl->i . 'M'; if ($intvl->s) $time .= $intvl->s . 'S'; if ($time) $time = 'T' . $time; $text ='P' . $date . $time; if ($text == 'P') return 'PT0S'; return $text; } ---- Server IP: 72.52.91.14 Probable Submitter: 98.169.66.145 ---- Manual Page -- http://php.net/manual/en/dateinterval.construct.php Edit -- https://master.php.net/note/edit/119260 Del: integrated -- https://master.php.net/note/delete/119260/integrated Del: useless -- https://master.php.net/note/delete/119260/useless Del: bad code -- https://master.php.net/note/delete/119260/bad+code Del: spam -- https://master.php.net/note/delete/119260/spam Del: non-english -- https://master.php.net/note/delete/119260/non-english Del: in docs -- https://master.php.net/note/delete/119260/in+docs Del: other reasons-- https://master.php.net/note/delete/119260 Reject -- https://master.php.net/note/reject/119260 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205391) next »