• 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

How to programmatically find public properties of a class from inside one of it's methods

Make Shipping Method fields Mandatory on Woocommerce checkout page

virtctl works when executed via command line but not from php exec()

Sentry on Symfony: how to exclude `NotFoundHttpException`

Input and output values for php into the browser?

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

Login if user is active using Laravel Breeze

LARAVEL: How to fetch id dynamically in a query builder?

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

Reducing authentication calls on external API (Laravel 5.6)

How to validate tin and cst using PHP?

How to disable widget block editor of WordPress?

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Encrypt in php and decrypt in Dart(flutter)

About Contact Privacy policy Terms and conditions