If you’re looking for a way to normalize a date into MySQL format, use the following
$phpdate = strtotime( $mysqldate ); $mysqldate = date( 'Y-m-d H:i:s', $phpdate );
The line $phpdate = strtotime( $mysqldate )
accepts a string and performs a series of heuristics to turn that string into a unix timestamp.
The line $mysqldate = date( 'Y-m-d H:i:s', $phpdate )
uses that timestamp and PHP’s date
function to turn that timestamp back into MySQL’s standard date format.
(Editor Note: This answer is here because of an original question with confusing wording, and the general Google usefulness this answer provided even if it didnt’ directly answer the question that now exists)
Related Posts:
- Object of class DateTime could not be converted to string
- How to log in to phpMyAdmin with WAMP, what is the username and password?
- Should I use mysqli_real_escape string() or mysql_real_escape_string() for form data?
- Fatal error: Call to undefined function mysql_connect()
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- http://localhost:80 is not working on running Apache server through UniServer ZeroXIII
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- Mysql query- How to use contains?
- mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
- Invalid column count in CSV input on line 1 Error
- Invalid column count in CSV input on line 1 Error
- $wpdb->update or $wpdb->insert results in slashes being added in front of quotes
- PDO with INSERT INTO through prepared statements
- phpMyAdmin: secret passphrase?
- PDO bindParam() with prepared statement isn’t working
- Forbidden :You don’t have permission to access /phpmyadmin on this server
- Converting string to Date and DateTime
- Creating a search form in PHP to search a database?
- How can I do ‘insert if not exists’ in MySQL?
- Fatal error: Call to a member function bind_param() on boolean [duplicate]
- Finding the number of days between two dates
- Compare given date with today
- MySqli Commands out of sync; you can’t run this command now
- Trying to get property of non-object in
- Is there a difference between the UTC and Etc/UTC time zones?
- Fix Access denied for user ‘root’@’localhost’ for phpMyAdmin
- Getting connection failed: php_network_getaddresses: getaddrinfo failed: Name or service not known
- Commands out of sync; you can’t run this command now
- Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
- PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client
- SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
- How can I do ‘insert if not exists’ in MySQL?
- What does it mean to escape a string?
- MAMP “Apache couldn’t be started because port is in use.” AND “Can’t connect to local MySQL server through /tmp/mysql.sock
- mysqli::query(): Couldn’t fetch mysqli
- Unexpected Exception: SQLSTATE[HY000] [1045] Access denied for user ****@’localhost’ (using password: YES)
- Uncaught Error: Call to undefined function mysql_escape_string()
- Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
- Call to a member function on null?
- Convert DateTime to String PHP
- SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens on line 102
- Warning: mysqli_query() expects parameter 1 to be mysqli, resource given
- MySQL query to get column names?
- What does MYSQLI_NUM mean and do?
- Mysql where id is in array
- ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
- What is the advantage of using try {} catch {} versus if {} else {}
- select * from table where column = value ^ column2= value
- Deprecated: mysql_query() [duplicate]
- No query results for model [App\Products] Laravel
- Fatal error: Call to a member function query() on null
- mysqlworkbench giving version error on exporting database
- How to make DROP INDEX IF EXISTS for mysql?
- What is the meaning of sprintf(): Too few arguments
- Having a problem getting mysqli_query to execute
- CodeIgniter: Unable to connect to your database server using the provided settings Error Message
- Can I store images in MySQL
- PHP: date function to get month of the current date
- MySQL Daemon Failed to Start – centos 6
- How to insert TIMESTAMP into my MySQL table?
- How to remove index.php from WordPress site URL
- PHP Like thing similar to MySQL Like, for if statement?
- How get value from URL
- How to use Memcached with PHP7?
- select count(*) from table of mysql in php
- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ””)’ at line 2
- mysqli_real_connect(): (HY000/2002): No such file or directory
- laravel updateOrCreate method
- How to listen messageSent event in laravel 5.5
- Make a HTTPS request through PHP and get response
- Multi-line strings in PHP
- cURL error 60: SSL certificate: unable to get local issuer certificate
- Replace spaces with a dash in a URL
- Child theme css not overriding parent
- Convert timestamp to readable date/time PHP
- Creating a php search bar
- Proper Format of iframe in PHP?
- How to find the last day of the month from date?
- php_network_getaddresses: getaddrinfo failed: Name or service not known (0) Failed To Connect..!
- Composer: Command Not Found
- Undefined variable: $_SESSION
- Error:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
- PHP Call to undefined function
- Formatting a number with leading zeros in PHP
- POST an array from an HTML form without javascript
- Changing user_nicename
- Sortable admin column for one meta key with three possible meta values
- AJAX in WordPress, sending coords data to MySQL and show after into map
- Is there a way to get 3+ dimensional array from a single MySql command
- Importing Geo data into wordpress database
- add category to posts with tag wordpress
- How can I Use 2 databases with one WordPress install
- Why won’t this wpdb get_results query return results?
- AWS Lightsail WordPress – connect to database on instance using mysqli
- Using wpdb to connect to a different database is not working
- Prepared DB Query from _POST array
- how to check for wordpress Query errors
- Putting form result in my database
- How can I update a value of a field depending on outside source?