Welcome to WebmasterWorld Guest from 54.167.250.64

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Please Explain with example How do I insert the date into the table

     
10:00 am on May 28, 2012 (gmt 0)

New User from US 

joined:Aug 6, 2011
posts:7
votes: 0


Please Explain with example How do I insert the date into the table in PHP ?
10:54 am on May 28, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Let's see your code and someone can guide you where you're going wrong.
12:41 pm on May 28, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Apr 19, 2002
posts:3322
votes: 29


have you considered just using a timestamp field in the database, and let it automatically enter the date
4:39 pm on May 29, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


Or a date type, or a datetime type.

For those, literal values must be quoted and in YYYY-MM-DD format. Date functions do not:

insert into tablename (my_date_only_field) values (curdate()); // date only

insert into tablename (my_date_and_time_field) values (now()); // date and time

insert into tablename (my_date_only_field) values ('2012-02-01'); // date only

insert into tablename (my_date_and_time_field) values ('2012-02-01 02:59:22'); // date and time

mySQL Date and Time [dev.mysql.com]
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members