Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrozenDate::createFromTimestamp doesnt use timezone correctly #81

Closed
markstory opened this issue Feb 13, 2016 · 2 comments
Closed

FrozenDate::createFromTimestamp doesnt use timezone correctly #81

markstory opened this issue Feb 13, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@markstory
Copy link
Member

From @Graziel on February 13, 2016 3:47

    <?php
use Cake\I18n\FrozenDate;
    ?>

    <?= date_default_timezone_get() ?>
    <?php $time1 = FrozenDate::create($year, $month, 1)->timestamp ?>
    <?= $time1 ?>
    <?= FrozenDate::createFromTimestamp($time1) ?>

    <?php date_default_timezone_set('Europe/Paris') ?>
    <?php $time3 = FrozenDate::create($year, $month, 1)->timestamp ?>
    <?= date('Y-m-d 00:00:00', $time3) ?>
    <?= $time3 ?>
    <?= FrozenDate::createFromTimestamp($time3) ?>

Gives:

    UTC 
    1454284800 
    01/02/2016 

    2016-02-01 00:00:00 
    1454284800 
    31/01/2016

but if im using

<?= new FrozenDate($time3) ?>

it gives correct result also while switching to \I18n\Date gives me

UTC 
1454284800 
01/01/1970 

2016-02-01 00:00:00 
1454284800 
01/01/1970

and again using

<?= new Date($time3) ?>

gives correct results

@markstory reminder "I bet I missed 'correcting' createFromTimestamp() then :)"

Copied from original issue: cakephp/cakephp#8251

@markstory markstory self-assigned this Feb 13, 2016
@markstory
Copy link
Member Author

I'll take a look. This might be an issue in cakephp/chronos.

@markstory markstory added this to the 0.5.0 milestone Feb 13, 2016
markstory added a commit that referenced this issue Feb 13, 2016
MutableDate was missing the important FrozenTimeTrait. Using this trait
lets a pile of duplicate code to be removed. add(), sub() were made
simpler by always calling setTime().

Refs #81
@markstory
Copy link
Member Author

Closing as a pull request is up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant