Re: [PHP] PHP modifying data from DB?
Hello Gabe, Friday, April 23, 2004, 7:20:14 PM, you wrote: G However, when I retrieve the date from DB using PHP, it displays the G following: G 2004-04-08 00:00:00 G Is PHP tacking on the zero's? I've tried using the date() function to G reformat it back to how I want it, but haven't gotten it to work. You are probably using a datetime field in your database, as opposed to a date field - which is where the extra zeros are coming from. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP modifying data from DB?
Hi Richard, I checked the field type in access and it is a date/time field (it's the only option). However, in access I told it to do a short date format mm/dd/. Unfortunately it still gives me those extra zero's. Let's say that getting those zero's is ok. Is this the code that I would write to form the proper date I want? $dbDate = value from the date field in the database date(m-d-Y, $dbDate); Richard Davey wrote: Hello Gabe, Friday, April 23, 2004, 7:20:14 PM, you wrote: G However, when I retrieve the date from DB using PHP, it displays the G following: G 2004-04-08 00:00:00 G Is PHP tacking on the zero's? I've tried using the date() function to G reformat it back to how I want it, but haven't gotten it to work. You are probably using a datetime field in your database, as opposed to a date field - which is where the extra zeros are coming from. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP modifying data from DB?
Have a look at strtotime() in addition to date() Richard Friday, April 23, 2004, 8:20:14 PM, thus was written: I have a field in a DB that contains a date. The format of the date is: 04/08/2004 However, when I retrieve the date from DB using PHP, it displays the following: 2004-04-08 00:00:00 Is PHP tacking on the zero's? I've tried using the date() function to reformat it back to how I want it, but haven't gotten it to work. Any ideas? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP modifying data from DB?
Here's what I tried and it seems to be working now. Thanks Richard! $var = date(m-d-Y, strtotime($dbDate)); $var then has the value of the date only. Still curious as to why those extra zero's are tacked on. Dare I mention it on this newsgroup, but when I used ASP I only got the date without the extra zero's. Richard Davey wrote: Hello Gabe, Friday, April 23, 2004, 7:33:53 PM, you wrote: G Let's say that getting those zero's is ok. Is this the code that I G would write to form the proper date I want? G $dbDate = value from the date field in the database G date(m-d-Y, $dbDate); Yeah that should be fine - you could do: date(m-d-Y 00:00:00, $dbDate); But I'm sure Access will add on the extra zeros if you do not specify them - would be worth testing to make sure though. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP modifying data from DB?
--- Gabe [EMAIL PROTECTED] wrote: Here's what I tried and it seems to be working now. Thanks Richard! $var = date(m-d-Y, strtotime($dbDate)); $var then has the value of the date only. Still curious as to why those extra zero's are tacked on. It's because MySQL is storing the date accurate to the second. Are you assuming the time is not stored, because you do a select at the MySQL prompt and don't see it? If so, that's the misunderstanding. Hope that helps. Chris = Chris Shiflett - http://shiflett.org/ PHP Security - O'Reilly Coming Fall 2004 HTTP Developer's Handbook - Sams http://httphandbook.org/ PHP Community Site http://phpcommunity.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php