• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How to set time with DateTime modify?

php


PHP Snippet 1:

$periodauction = '2018-04-09T10:00:00';
$date = DateTime::createFromFormat('Y-m-d\TH:i:s', $periodauction)->modify('-1 day');
$date->setTime(18,0);
echo $date->format('Y-m-d\TH:i:s');

PHP Snippet 2:

2018-04-08T18:00:00

Related Snippets

php - add comma thousands separator but remove trailing zeros

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Detect if PHP session exists

Dynamic table in HTML using MySQL and php

Check If array is null or not in php

How to get AJAX to post on second page?

Split comma separated value from table column into rows using mysql?

Laravel csrf token mismatch for ajax POST Request

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Get data from accuweather api url

Converting IPv6 to IPv4 address in PHP

PHP rotate matrix counter-clockwise

oauth-private.key does not exist or is not readable

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

Problems getting instance of UploadedFile in Yii2

About Contact Privacy policy Terms and conditions