converting date into database date format(newbie)

This is a discussion on converting date into database date format(newbie) within the PHP General forums, part of the PHP Programming Forums category; Hi! U can convert "8-Aug-03" into mysql date which requires yyyy-mm-dd format as below. &...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-28-2003
Binay Agarwal
 
Posts: n/a
Default Re: [PHP] converting date into database date format(newbie)

Hi!

U can convert "8-Aug-03" into mysql date which requires yyyy-mm-dd format as
below.

<?php
date("Y-m-d",strtotime("8-Aug-03"));

?>

Hope this helps and let me know.

Cheers

Binay

----- Original Message -----
From: "Anil Garg" <anilg@niksun.com>
To: <php-general@lists.php.net>
Sent: Friday, August 29, 2003 11:01 AM
Subject: [php] converting date into database date format(newbie)


> Hi,
>
> I am a newbie to php.
>
> I am reading date in the format "08-Aug-03" from a text file. While

writing
> this date into the myqsl database's date column it shows '00-00-0000'.
> Is there a function or some other way to convert "08-Aug-03" type of dates
> in to format which is acceptable by date field of the mysql database.
>
> Thanks and regards
> Anil.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply With Quote
  #2 (permalink)  
Old 08-29-2003
Anil Garg
 
Posts: n/a
Default converting date into database date format(newbie)

Hi,

I am a newbie to php.

I am reading date in the format "08-Aug-03" from a text file. While writing
this date into the myqsl database's date column it shows '00-00-0000'.
Is there a function or some other way to convert "08-Aug-03" type of dates
in to format which is acceptable by date field of the mysql database.

Thanks and regards
Anil.
Reply With Quote
  #3 (permalink)  
Old 08-29-2003
John W. Holmes
 
Posts: n/a
Default Re: [PHP] converting date into database date format(newbie)

Anil Garg wrote:

> I am reading date in the format "08-Aug-03" from a text file. While writing
> this date into the myqsl database's date column it shows '00-00-0000'.
> Is there a function or some other way to convert "08-Aug-03" type of dates
> in to format which is acceptable by date field of the mysql database.


MySQL expects it's date in a YYYY-MM-DD or YYYYMMDD format. Try using
soething like this:

$mysql_date = date('Ymd',strtotime($date_from_text_file));

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:48 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0