Professional Web Applications Themes

Inserting Current Date into MySQL Database - PHP Development

OK, I am a complete Newbie at this, well... almost... I am creating a database that accepts members. I need to know how to insert the date of joining into the database, using a PHP script. Obviously this has to be done without using an input field. I can't provide specific code because it is a general principle I am after so I can utilise it in a number of scripts....

  1. #1

    Default Inserting Current Date into MySQL Database

    OK, I am a complete Newbie at this, well... almost...

    I am creating a database that accepts members. I need to know how to insert
    the date of joining into the database, using a PHP script. Obviously this
    has to be done without using an input field.

    I can't provide specific code because it is a general principle I am after
    so I can utilise it in a number of scripts.


    Gerard Shea Guest

  2. #2

    Default Re: Inserting Current Date into MySQL Database

    I just wish to clarify that I am using an "Insert Record" server behaviour -
    if that makes any difference...

    "Gerard Shea" <gpshea@tsn.cc> wrote in message news:4125a14d$1@grungy...
    > OK, I am a complete Newbie at this, well... almost...
    >
    > I am creating a database that accepts members. I need to know how to
    insert
    > the date of joining into the database, using a PHP script. Obviously this
    > has to be done without using an input field.
    >
    > I can't provide specific code because it is a general principle I am after
    > so I can utilise it in a number of scripts.
    >
    >


    Gerard Shea Guest

  3. #3

    Default Re: Inserting Current Date into MySQL Database

    On Fri, 20 Aug 2004 07:02:29 GMT, "Gerard Shea" <gpshea@tsn.cc> wrote:
    >OK, I am a complete Newbie at this, well... almost...
    >
    >I am creating a database that accepts members. I need to know how to insert
    >the date of joining into the database, using a PHP script. Obviously this
    >has to be done without using an input field.
    >
    >I can't provide specific code because it is a general principle I am after
    >so I can utilise it in a number of scripts.
    >
    I have a column in each table

    FIELD date_added TYPE date

    then, in the php code -

    $Query="INSERT INTO $TableName ( field1, field2.... date_added ) VALUES
    ('$field1', '$field2', ... curdate() )";

    Clearly, this does not need an input field in your forms.

    HTH.
    ------------------------------------------------------------

    This post did not necessarily reflect my opinions. So there.

    Sent from within Forte's Agent.

    Pull the pins out to reply direct.
    Fat Bloke Guest

  4. #4

    Default Re: Inserting Current Date into MySQL Database

    To get the current date via SQL, use this:

    NOW()

    as in :
    INSERT INTO tablename (field1,field2,date_field)
    VALUES('field1_value','field2_value',NOW());


    "Fat Bloke" <fatblokeonbikepins@pinsjohnstone-wheelers.co.uk> wrote in
    message news:859bi0d9bkd3loaggplhqvubv5nvglgrc3@4ax.com...
    > On Fri, 20 Aug 2004 07:02:29 GMT, "Gerard Shea" <gpshea@tsn.cc> wrote:
    >
    > >OK, I am a complete Newbie at this, well... almost...
    > >
    > >I am creating a database that accepts members. I need to know how to
    insert
    > >the date of joining into the database, using a PHP script. Obviously
    this
    > >has to be done without using an input field.
    > >
    > >I can't provide specific code because it is a general principle I am
    after
    > >so I can utilise it in a number of scripts.
    > >
    > I have a column in each table
    >
    > FIELD date_added TYPE date
    >
    > then, in the php code -
    >
    > $Query="INSERT INTO $TableName ( field1, field2.... date_added ) VALUES
    > ('$field1', '$field2', ... curdate() )";
    >
    > Clearly, this does not need an input field in your forms.
    >
    > HTH.
    > ------------------------------------------------------------
    >
    > This post did not necessarily reflect my opinions. So there.
    >
    > Sent from within Forte's Agent.
    >
    > Pull the pins out to reply direct.

    Charles Pelkey Guest

  5. #5

    Default Re: Inserting Current Date into MySQL Database

    Gerard Shea wrote:
    > OK, I am a complete Newbie at this, well... almost...
    >
    > I am creating a database that accepts members. I need to know how to
    > insert
    > the date of joining into the database, using a PHP script. Obviously this
    > has to be done without using an input field.
    >
    > I can't provide specific code because it is a general principle I am after
    > so I can utilise it in a number of scripts.
    For user who join NOW, ie, real-time.
    1. Grab the current system time (ie, system clock on the we server)
    2. Format #1 appropriately for the database
    3. SQL insert statement.

    For loading up historical data.
    1. Load join dates from a source (other database, file, etc)
    2. Format #1....etc
    3. SQL insert.

    Which bit are you stuck on? If you need to take into account time zones,
    then the client's browser may provide some useful hints.

    Cheers

    James
    --
    "Life is too important to take seriously."
    -- Corky Siegel

    Centurion Guest

Similar Threads

  1. Trouble inserting date into database
    By cshow365 in forum Coldfusion Database Access
    Replies: 4
    Last Post: September 19th, 06:39 AM
  2. inserting date into MySql Database
    By khotwheels in forum Coldfusion Database Access
    Replies: 3
    Last Post: September 2nd, 12:59 AM
  3. inserting system or current date
    By akcreative in forum Coldfusion Database Access
    Replies: 4
    Last Post: September 1st, 10:24 PM
  4. Simple Problem - Inserting current date into table
    By juniorbee in forum Dreamweaver AppDev
    Replies: 2
    Last Post: February 22nd, 04:06 PM
  5. inserting the current date into mysql database fild
    By Paul Brown in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 24th, 03:51 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