• 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 properly set "0000-00-00 00:00:00" as a DateTime in PHP

phpsymfonydatetimedoctrine-orm


PHP Snippet 1:

$entEmail = new Email();
$entEmail->setViewedAt(null);

PHP Snippet 2:

$Date = date('Y-m-d H:i:s');

PHP Snippet 3:

date_default_timezone_set('America/New_York');
$date = date('Y-m-d H:i:s');

$entEmail = new Email();
$entEmail->setViewedAt( $date );

PHP Snippet 4:

date_default_timezone_set('America/New_York');

$entEmail = new Email();
$entEmail->setViewedAt( date('Y-m-d H:i:s') );

Related Snippets

Detect if PHP session exists

Pagekite error: FAIL: localhost:8080 is down

Apply session id from request header

Laravel/docker-compose/redis - Class 'Redis' not found

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Group rows by column and sum another column within groups [duplicate]

Insert a DIV after the 6th product only once in WooCommerce category archives

Correctly determine if date string is a valid date in that format

Apply filter array/return terms

Laravel 5.5 change unauthenticated login redirect url

Laravel 5.2: Unable to locate factory with name [default]

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Filter array by skipping every nth element from the end

Star and Half Star Rating in Laravel

Transfer data between JavaScript and PHP through JSON

About Contact Privacy policy Terms and conditions