Insert current date in datetime format mySQL

0 votes

I am having an issue inserting date properly into the  database.

$date = date('m/d/Y h:i:s', time());

I use this format, and, it echoes out correctly, however, when, I insert:

mysql_query("INSERT INTO table 
(dateposted) 
VALUES ('$date')");

But it doesn't work. Can someone please help me with this?

Jun 25, 2022 in PHP by narikkadan
• 63,600 points
590 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to convert from MySQL datetime to another format with PHP?

Hello, To convert a date retrieved from MySQL ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,840 points
3,522 views
0 votes
1 answer

How to output MySQL query results in CSV format?

Hello @kartik, Using this command columns names will ...READ MORE

answered Aug 18, 2020 in PHP by Niroj
• 82,840 points
2,562 views
0 votes
1 answer

How to convert timestamp to date in MySQL query?

Hello @kartik, Try this: DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS ...READ MORE

answered Aug 19, 2020 in PHP by Niroj
• 82,840 points
7,871 views
0 votes
1 answer

How to convert a string to date in mysql?

Hello @kartik, you can do SELECT STR_TO_DATE(yourdatefield, '%m/%d/%Y') FROM ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,840 points
2,522 views
0 votes
1 answer

How MySQL date format DD/MM/YYYY select query?

Hello @kartik, You can use STR_TO_DATE() to convert your strings ...READ MORE

answered Aug 26, 2020 in PHP by Niroj
• 82,840 points
8,175 views
0 votes
0 answers

Convert one date format into another in PHP

How can I convert one date format ...READ MORE

Jun 20, 2022 in PHP by Kithuzzz
• 38,000 points
304 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,539 views
0 votes
1 answer

Why is not preferable to use mysql_* functions in PHP?

The reasons are as follows: The MySQL extension: Does ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,250 points
1,268 views
0 votes
2 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP