
- 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
Print the time an hour ago PHP?
To print time an hour ago, you need to subtract -1 hour. Use the strtotime() method and set the subtraction value in it i.e. -1 for 1 hour ago time, -2 for 2 hour ago time, etc.
Let’s say the current time is
18:42:22
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php $oneHourAgo= date('Y-m-d H:i:s', strtotime('-1 hour')); echo 'One hour ago, the date = ' . $oneHourAgo; ?> </body> </html>
Output
This will produce the following output
One hour ago, the date = 2020-09-26 17:42:22
- Related Questions & Answers
- PHP program to convert a given timestamp into time ago
- How to convert 12-hour time scale to 24-hour time in R?
- 24-hour time in Python
- Converting 12 hour format time to 24 hour format in JavaScript
- PHP print keys from an object?
- C# program to convert time from 12 hour to 24 hour format
- Python program to convert time from 12 hour to 24 hour format
- C++ program to convert time from 12 hour to 24 hour format
- Convert time from 24 hour clock to 12 hour clock format in C++
- Set the hour for a specified date according to universal time?
- Python Pandas - Extract the hour from the DateTimeIndex with specific time series frequency
- Java Program to display Time in 12-hour format
- Java Program to display time in 24-hour format
- Python Pandas - Format the Period object and display the Time with 24-Hour format
- Insert current time minus 1 hour to already inserted date-time records in MYSQL
Advertisements