Welcome Guest, Not a member yet? Register   Sign In
Using Maria/MySQL Internal Time Functions in the Builder Class?
#2

Because CodeIgniter no longer has the now() method.

Here I created a helper to do it, make sure to place the methods into a help file.

PHP Code:
/ -----------------------------------------------------------------------

/**
 * now () method
 */
if ( ! function_exists('now'))
{
    function 
now()
    {
        
// uses the default timezone.
        
return date_create('now')->format('Y-m-d H:i:s');
    }
}

// -----------------------------------------------------------------------

/**
 * nowTimeZone () method
 */
if ( ! function_exists('nowTimeZone'))
{
    function 
nowTimeZone($timeZone)
    {
        
// $timeZone format 'America/New_York'
        
return date_create('now'timezone_open($timeZone))->format('Y-m-d H:i:s');
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
RE: Using Maria/MySQL Internal Time Functions in the Builder Class? - by InsiteFX - 09-09-2020, 05:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB