note 58000 added to function.date

From: Date: Fri, 21 Oct 2005 03:03:22 +0000
Subject: note 58000 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-97336@lists.php.net to get a copy of this message
<?php /** * function dateconvert * * dateconvert is a handy function to take the aches and pains out of mysqls stupidity * by converting data from a variable (posted from a form or just stored) * into a format mysql will be able to store and converting the * database date back into the british standard of date month year. * The Script accepts day.month.year or day/month/year or day-month-year. * example: * * <code> * <?php // using type 1 * $date = "19.12.2005"; * $date = dateconvert($date, 1); * echo $date; // Would echo 2005-12-19 which is the format stored by mysql * ?> * </code> * <code> * <?php // using type 2 * $date = $row['date']; //your mysql date * $realdate = dateconvert($date,2); * echo $realdate; // would display 19/12/2005 * ?> * </code> * * @author Chris McKee <pcdevils@gmail.com> * * @param string $date - Date to be converted * @param string $func - which function is to be used (1 for input to mysql, 2 for output from mysql) */ function dateconvert($date,$func) { if ($func == 1){ //insert conversion list($day, $month, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$day/$month/$year"; return $date; } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58000 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58000&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58000&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97336) next »