Professional Web Applications Themes

converting date into database date format(newbie) - PHP Development

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" <anilgniksun.com> To: <php-generallists.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 ...

  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" <anilgniksun.com>
    To: <php-generallists.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. #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

  3. #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

Similar Threads

  1. Date Format in Com+
    By news.microsoft.com in forum ASP Components
    Replies: 0
    Last Post: July 12th, 03:41 PM
  2. How to export database date to Csv format
    By nic in forum ASP Database
    Replies: 1
    Last Post: January 8th, 04:13 AM
  3. Converting Date Formats?
    By Kit in forum PHP Development
    Replies: 6
    Last Post: November 12th, 04:03 PM
  4. Date format Help.
    By bill in forum Microsoft Access
    Replies: 1
    Last Post: July 26th, 11:19 PM
  5. Converting Date
    By bigforehand in forum Macromedia Dynamic HTML
    Replies: 2
    Last Post: July 15th, 04:18 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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