

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert PHP variable “11:00 AM” to MySQL time format?
Use DateTime to convert PHP variable “11:00 AM: to MySQL time format.
The PHP code is as follows −
$phpTime = '11:00 AM'; echo('The PHP Time Format is ='); echo ($phpTime); $timeFormat = DateTime::createFromFormat( 'H:i A', $phpTime); $MySQLTimeFormat = $timeFormat->format( 'H:i:s'); echo (' '); echo('The MySQL Time Format is ='); echo ($MySQLTimeFormat);
The snapshot of PHP code is as follows −
Here is the output −
The PHP Time Format is =11:00 AM The MySQL Time Format is =11:00:00
- Related Questions & Answers
- How to convert varchar “time” to real time in MySQL?
- MySQL format time with lowercase am/pm?
- Display hour in KK (00-11) format in Java
- How to convert C# DateTime to “YYYYMMDDHHMMSS” format?
- Display AM/PM time marker with SimpleDateFormat(“a”) in Java
- Java Program to Format time in AM-PM format
- Format MySQL CURRENT_TIMESTAMP to AM & PM?
- Java Program to display hour in K (0-11 in AM/PM) format
- C# Exponential (“E”) Format Specifier
- C# Numeric (“N”) Format Specifier
- How to format number with “.” as thousand separators, and “,” as decimal separator?
- C# Fixed-Point (“F”) Format Specifier
- Order dates in MySQL with the format “01 August 2019”?
- How to check for “undefined” variable in JavaScript?
- How to work with “!=” or “not equals” in MySQL WHERE?
Advertisements