DATE Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jessy
    New Member
    • Oct 2006
    • 106

    DATE Problem

    i need to insert a date into MYSQL DB which the user selects the DAY MONTH YEAR from 3 combo boxes
    [code=php]
    $day=$_POST['day'];
    $month=$_POST['month'];
    $year=$_POST['year'];
    [/code]
    im not sure whether to make the DB field DATE or TIMESTAMP ..
    and if so ..how can i insert it into the database if it was a TIMESTAMP ??
    Last edited by Atli; Oct 2 '08, 07:08 PM. Reason: Added [code] tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Jessy.

    Regardless of the field's type, you can still enter it the same way:

    [code=php]
    $query = "INSERT INTO `table` SET `date` = '{$year}-{$month}-{$day}'"
    [/code]

    If you need to be able to log the time as well as the date, make it a datetime. Otherwise just use date to save space.

    Timestamp is more for internal stuff (generally to record exactly when a record is added or changed).

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      jessy.

      Once again; please use [code] tags when posting code examples.

      You have already been warned several times about violating the Posting Guidelines, not to mention that your account has already been temporarily suspended for a violation similar to this one.
      I would expect you to have gotten the message by now.

      We do not like having to issue warnings or bans, but enough is enough.

      This will be your last warning. Next time you violate the guidelines your account will be banned permanently.

      Thank you
      MODERATOR

      Comment

      Working...