Skip to content

Carbon::createFromFormat using a date without time does not respect Carbon::setTestNow #1280

@Naouak

Description

@Naouak

When using createFromFormat without a time, instead of using the time fixed by setTestNow, it use current time of the server which is not the expected behavior.

To reproduce:

<?php
require('vendor/autoload.php');
Carbon\Carbon::setTestNow(Carbon\Carbon::createFromFormat("Y-m-d H:i:s", '2018-01-01 00:00:00'));
$date = Carbon\Carbon::createFromFormat("Y-m-d", "2018-05-06");
$date->hour == 0 || die("Invalid time");
?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions