converting date into database date format(newbie)

Ask a Question related to PHP Development, Design and Development.

  1. #1

    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
    >
    >
    Binay Agarwal Guest

  2. Similar Questions and Discussions

    1. How to export database date to Csv format
      I am using MS Access. Please show me how to export databse date to CSV format. Thanks
    2. Converting Date Formats?
      Howdy! I have some dates in a MySQL database that are in a 'Y-m-d' format. Is there a way to have PHP read these dates and convert them to a...
    3. Date format Help.
      I have a field set to short date 99;99;00;0, and it appears as soon as I tab to the next couple of fields that the previous date field changes to...
    4. Converting raw numbers to written date
      How would you decipher a stamp like 12303 Is it 1/23/03 or 12/3/03 ------------------------------------------------- d l b j r Unambit...
    5. Converting Date
      In PHP with MySQL: My table stores the date as 2003/10/07 ... (year, day, month). I want to be able to convert it to 07/10/2003 before I echo it...
  3. #2

    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.
    Anil Garg Guest

  4. #3

    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: [url]www.amazon.com/o/registry/3BEXC84AB3A5E/[/url]

    php|architect: The Magazine for PHP Professionals – [url]www.phparch.com[/url]
    John W. Holmes Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139