Skip to content

Commit a4f21e8

Browse files
committed
replace time() to time class into date_helper
1 parent 7fac366 commit a4f21e8

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

system/Helpers/date_helper.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/**
4+
* This file is part of CodeIgniter 4 framework.
5+
*
6+
* (c) CodeIgniter Foundation <admin@codeigniter.com>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
use CodeIgniter\I18n\Time;
13+
314
/**
415
* This file is part of CodeIgniter 4 framework.
516
*
@@ -15,7 +26,7 @@
1526
/**
1627
* Get "now" time
1728
*
18-
* Returns time() based on the timezone parameter or on the
29+
* Returns Time::now()->getTimestamp() based on the timezone parameter or on the
1930
* app_timezone() setting
2031
*
2132
* @param string $timezone
@@ -27,7 +38,7 @@ function now(?string $timezone = null): int
2738
$timezone = empty($timezone) ? app_timezone() : $timezone;
2839

2940
if ($timezone === 'local' || $timezone === date_default_timezone_get()) {
30-
return time();
41+
return Time::now()->getTimestamp();
3142
}
3243

3344
$datetime = new DateTime('now', new DateTimeZone($timezone));

0 commit comments

Comments
 (0)