includes/helpers.php
/**
	 * Converts a unix seconds timestamp to a SQL `DATETIME` value with an optional timezone.
	 *
	 * Passing a timezone into the second parameter will override the application's global timezone as configured in
	 * your `config/app.php` file. We recommend using a consistent timezone across your application and database.
	 *
	 * @param int $timestamp
	 * @param string|null $timezone
	 * @return string
	 */
Converts a unix seconds timestamp to a SQL `DATETIME` value with an optional timezone.
Passing a timezone into the second parameter will override the application's global timezone as configured in
your `config/app.php` file. We recommend using a consistent timezone across your application and database.

@param int $timestamp
@param string|null $timezone
@return string
Converts a unix seconds timestamp to a SQL ` DATETIME ` value with an optional timezone . Passing a timezone into the second parameter will override the application ' s global timezone as configured in your ` config / app . php ` file . We recommend using a consistent timezone across your application and database . @param int $timestamp @param string|null $timezone @return string
function timestamp_to_datetime($timestamp, $timezone = null) {
		$date = DateTime::createFromFormat('U', $timestamp);
		if ($timezone === null) {
			$timezone = config('app.timezone');
		}
		$date->setTimezone(new DateTimeZone($timezone));
		return $date->format('Y-m-d H:i:s');
	}
function timestamp_to_datetime ( $ timestamp , $ timezone = null ) { $ date = DateTime :: createFromFormat ( 'U' , $ timestamp ) ; if ( $ timezone === null ) { $ timezone = config ( 'app.timezone' ) ; } $ date -> setTimezone ( new DateTimeZone ( $ timezone ) ) ; return $ date -> format ( 'Y-m-d H:i:s' ) ; }
Converts a unix seconds timestamp to a SQL `DATETIME` value with an optional timezone.
Converts a unix seconds timestamp to a SQL ` DATETIME ` value with an optional timezone .