Skip to content

Conversation

@kenjis
Copy link
Member

@kenjis kenjis commented Mar 26, 2024

Description
See https://forum.codeigniter.com/showthread.php?tid=90472

This may be a bug, but I don't know how to fix.

        $current = Time::parse('2024-03-31', 'Europe/Madrid');
        $test    = Time::parse('2024-04-01', 'Europe/Madrid');

        $diff = $current->difference($test);

        echo $diff->getDays(); // 0

        $current = new DateTimeImmutable('2024-03-31', new DateTimeZone('Europe/Madrid'));
        $test    = new DateTimeImmutable('2024-04-01', new DateTimeZone('Europe/Madrid'));

        $diff = $current->diff($test);

        echo $diff->format("%a"); // 1

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • [] Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the documentation Pull requests for documentation only label Mar 26, 2024

use CodeIgniter\I18n\Time;

$current = Time::parse('2024-03-31', 'Europe/Madrid');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to this PR, but I recently read the documentation for Time::class.
The point is that dates in the database are commonly stored as yyyy-MM-dd HH:mm:ss, but there is no example of using this form in the document. I think you can use 2024-03-31 00:00:00 instead of 2024-03-31 .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent #8668

@kenjis
Copy link
Member Author

kenjis commented Mar 26, 2024

I sent another PR to fix the behavior: #8659

@kenjis kenjis mentioned this pull request Mar 26, 2024
5 tasks
@kenjis kenjis closed this Mar 27, 2024
@kenjis kenjis deleted the docs-add-note-to-time-difference branch March 27, 2024 12:33
@kenjis
Copy link
Member Author

kenjis commented Mar 27, 2024

Go to #8661

@kenjis kenjis mentioned this pull request Mar 27, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Pull requests for documentation only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants