Asked 10 years, 1 month ago
Viewed 28k times
I would like to show me the date minus 5 minutes from the current time; my code is like this:
[date['Y-m-d H:i-5:s']]
but it's not correct because var_dump
produces:
2012-08-08 13:27-5:49
Any ideas on how can I do this?
Marcello B.
3,90211 gold badges46 silver badges62 bronze badges
asked Aug 8, 2012 at 17:31
PHP Function:
strtotime[]
Example:
echo date['Y-m-d H:i:s', strtotime['-5 minutes']];
salathe
50.4k11 gold badges103 silver badges130 bronze badges
answered Aug 8, 2012 at 17:33
Jason McCrearyJason McCreary
69.8k21 gold badges128 silver badges170 bronze badges
3
Try this It's solve your problem
$format = "h:i A";
date_default_timezone_set['Asia/Kolkata'];
echo date[$format, strtotime["-5 minute"]];
answered Jan 15, 2018 at 10:54
vivekvivek
3542 silver badges9 bronze badges
November 12, 2021 Category : PHP
This tutorial will give you example of php subtract minutes from datetime. i explained simply about php subtract minutes from current time. We will use how to subtract minutes from time in php. This article goes in detailed on how to subtract minutes from current time in php.
I will give you very simple example how to sub minutes to date and time in PHP. so let's see both example with output:
Example 1: PHP Subtract Minutes to DateTime
index.php
Output:
2021-11-01 10:00:05
Example 2: PHP Subtract Minutes to Current DateTime
index.php
Output:
2021-11-10 06:39:33
i hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
Follow Me:
We are Recommending you
- How to Add Seconds to Time in PHP?
- PHP Add Minutes to Time Example
- PHP Add Hours to Datetime Example
- PHP Subtract Year from Date Example
- PHP Subtract Month from Date Example
- How to Subtract Days to Date in PHP?
- How to Add Year to Date in PHP?
- How to Add Months to Date in PHP?
- How to Add Days to Date in PHP?
Popular Posts
- Laravel 6 CRUD Application Tutorial
- How to get filename from file path in MySQL?
- Laravel - Dynamic Dependant Select Box using JQuery Ajax Example - Part 1
- How to change date format in PHP Codeigniter?
- How to Convert Array to String in PHP?
- PHP Codeigniter 3 - Jquery Ajax Autocomplete Search using Typeahead
- Laravel 5.6 Import Export to Excel and CSV example
- Laravel Many to Many Polymorphic Relationship Tutorial
- How to call middleware from controller in Laravel?
- Laravel age calculate from date using carbon
- Php jquery ajax post request example
Categories
- Laravel
- Angular
- PHP
- jQuery
- Bootstrap
- Python
- Javascript
- MySql
- Ajax
- Node JS
- HTML
- Codeigniter
- Ubuntu
- Guest Post
- Vue.JS
- React JS
- Git
- Server
- JSON
- Installation
- CSS
- Google Map
- SQL
- .htaccess
- Google API
- JQuery UI
- Axios
- Typeahead JS
- Socket.io
- Highcharts
Latest Posts
- 13 High-Paying IT Jobs You Can Get Without a Degree
- How to Get All Routes in Laravel?
- Laravel Download File from URL to Storage Example
- How to Remove Numbers from String in PHP?
- How to Write Text on Existing PDF File in Laravel?