By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

DATE Problem

100+
P: 106
i need to insert a date into MYSQL DB which the user selects the DAY MONTH YEAR from 3 combo boxes
Expand|Select|Wrap|Line Numbers
  1.  $day=$_POST['day'];
  2.  $month=$_POST['month'];
  3.  $year=$_POST['year'];
  4.  
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 ??
Oct 2 '08 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Heya, Jessy.

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

Expand|Select|Wrap|Line Numbers
  1. $query = "INSERT INTO `table` SET `date` = '{$year}-{$month}-{$day}'"
  2.  
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).
Oct 2 '08 #2

Atli
Expert 5K+
P: 5,058
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
Oct 2 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.