php-db | 2001011
Date: 12/29/00
- Next message: Andy Etemadi: "Re: [PHP-DB] time from Mysql to php"
- Previous message: Adv. Systems Design: "[PHP-DB] sorting"
- Next in thread: Andy Etemadi: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: Andy Etemadi: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: Glen Scott: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: Jaskirat Singh: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: php3 <email protected>: "Re: [PHP-DB] time from Mysql to php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Yes. I spent a bit of time messing about with this, and here's some code
from my experiments. $dtAuctionStart is from a table, you'll see it's
format below. Sorry if this gets wrapped ...
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));
?>
So chew away on this, you'll see that some of the assumptions return very
strange dates, as $dtAuctionStart was something like 20001015.
I didn't have to use time's in that table, so it never got explored. The
tightest interpretation is the "ereg", I find it easier to under stand if I
extract substrings.
Hope this helps - Miles Thompson
At 04:32 PM 12/29/2000 -0800, Kevin McCarthy wrote:
>I have several tables that use a date field but for the life of me I can't
>figure how to use the values to show dates/times in various formats in PHP.
>
>The gist of it is, I capture timestamps in a MySQL record as
>'20001229162800'. I need to use this value to show a time/date in PHP but
>none of the PHP date/time functions seem to recognize this as a valid date
>string.
>
>Do I need to perform a conversion on this string in order to further
>format it in display?
>
>TIA.
>
>
>
>Kevin McCarthy Body & Soul
>http://www.bodynsoul.com
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-db-unsubscribe <email protected>
>For additional commands, e-mail: php-db-help <email protected>
>To contact the list administrators, e-mail: php-list-admin <email protected>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Andy Etemadi: "Re: [PHP-DB] time from Mysql to php"
- Previous message: Adv. Systems Design: "[PHP-DB] sorting"
- Next in thread: Andy Etemadi: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: Andy Etemadi: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: Glen Scott: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: Jaskirat Singh: "Re: [PHP-DB] time from Mysql to php"
- Maybe reply: php3 <email protected>: "Re: [PHP-DB] time from Mysql to php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

