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

(09-09-2020, 05:26 AM)InsiteFX Wrote: 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');
    }


Thanks man for the helper, I figured there was something along those lines going on, but just wasn't sure what it was.
Reply


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



Theme © iAndrew 2016 - Forum software by © MyBB