Re: Date formatting
| From: | Miles Thompson | Date: | Tue, 11 Dec 2001 21:43:58 +0000 |
| Subject: | Re: Date formatting | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-77357@lists.php.net to get a copy of this message | ||
Here, play with this. dtAuctionStart is a MySQL date field, so substitute your own connection and var.
Have fun - Miles Thompson
Some messing about with dates <br>
=============================<br>
<?
echo $dtAuctionStart, "<br>";
echo date ("Y-m-d", $dtAuctionStart ), "<br>";
//$strDate = $dtAuctionStart ;
echo "dtAuctionStart : $dtAuctionStart";
$year = substr ($dtAuctionStart, 0, 4); $month = substr( $dtAuctionStart, 4, 2 ); $day = substr ($dtAuctionStart, 6, 2 );Echo "dtAuctionStart in m-d -y : $month-$day-$year <br>"; $workdate = getdate( $dtAuctionStart ); echo " Workdate Year:", $workdate["year"],"<br>"; ?> Ereg Stuff <br> ==========<br> <? if (ereg ("([0-9]{4})([0-9]{1,2})([0-9]{1,2})", $dtAuctionStart, $regs)) {
echo "Auction Start: $regs[1]-$regs[2]-$regs[3] <br><br>";} else {
echo "Bad date format. <br>";} //echo gmdate ("Y-m-d", time()), "<br>"; echo date ("M-d-Y", mktime (0,0,0, $month, $day, $year)); // echo date ("M-d-Y", mktime (0,0,0,12,32,1997)); echo "<br>Local date: <br> " ; echo date ("M d Y H:i:s", time()), "<br>"; echo date ("M d Y H:i:s", time()), "<br>"; echo "Greenwich date: <br>"; echo gmdate ("M d Y H:i:s", time()), "<br>"; echo gmdate ("YmdHis", time()), "<br>"; ?> At 09:35 PM 12/10/2001 -0600, phantom wrote:
What would be an easy what to format a date value into month day year?? I want to specially display a date stored in mysql in date format YYYY-MM-DD The manual says: string date (string format, int [timestamp]) I tried $FormattedDate = date("F y, Y",${StoredDate}) 1999-04-15 spit out December 31, 1969 when I had hoped for April 15, 1999. Apparently YYYY-MM-DD is not a valid timestamp... i tried mysql formats of timestamp(8) and timestamp(14) and that didn't work either -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net