Welcome Guest, Not a member yet? Register   Sign In
Dating Helper Questions
#1

hello,

I just look at the CI4 code and when I look at the function date_helper->now I'm not quite sure in what situations this function would be used.

from what i saw This function returns a timestamp for a given time zone.

But the AFAIK timestamp is an unrelated time zone. No matter what time zone you are in If you search for the timestamp at the same time (Synced action) You will get the same timestamp.
ป๊อกเด้งฝากถอนauto
If I misunderstand this function please let us know
Reply
#2

(This post was last modified: 08-25-2022, 09:59 PM by kenjis.)

Good question.
It seems the timezone affects the now() result.

PHP Code:
        helper('date');

        $now        now();
        $nowChicago now('America/Chicago');

        echo config('App')->appTimezone PHP_EOL;
        echo $now ': ';
        echo Time::createFromTimestamp($now)->format(DateTimeInterface::ATOM);
        echo PHP_EOL;
        echo $nowChicago ': ';
        echo Time::createFromTimestamp($nowChicago)->format(DateTimeInterface::ATOM);
        echo PHP_EOL

Results:
Code:
UTC
1661488105: 2022-08-26T04:28:25+00:00
1661470105: 2022-08-25T23:28:25+00:00

I recommend you don't use now().
CI4 has the Time class.
https://codeigniter4.github.io/CodeIgnit.../time.html

PHP Code:
        $now Time::now();
        $nowChicago Time::now('America/Chicago');

        echo $now->getTimestamp() . ': ';
        echo $now->format(DateTimeInterface::ATOM);
        echo PHP_EOL;
        echo $nowChicago->getTimestamp() . ': ';
        echo $nowChicago->format(DateTimeInterface::ATOM);
        echo PHP_EOL

Results:
Code:
1661489866: 2022-08-26T04:57:46+00:00
1661489866: 2022-08-25T23:57:46-05:00
Reply
#3

The in-progress user guide is updated. How about this?
https://codeigniter4.github.io/CodeIgnit...r.html#now
Reply




Theme © iAndrew 2016 - Forum software by © MyBB