includes/helpers.php
/**
	 * Converts a SQL `DATETIME` value to a unix seconds timestamp 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 string $datetime
	 * @param string|null $timezone
	 * @return int
	 */
Converts a SQL `DATETIME` value to a unix seconds timestamp 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 string $datetime
@param string|null $timezone
@return int
Converts a SQL ` DATETIME ` value to a unix seconds timestamp 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 string $datetime @param string|null $timezone @return int
function datetime_to_timestamp($datetime, $timezone = null) {
		if ($timezone === null) {
			$timezone = config('app.timezone');
		}
		$timezone = new DateTimeZone($timezone);
		$time = new DateTime($datetime, $timezone);
		return $time->getTimestamp();
	}
function datetime_to_timestamp ( $ datetime , $ timezone = null ) { if ( $ timezone === null ) { $ timezone = config ( 'app.timezone' ) ; } $ timezone = new DateTimeZone ( $ timezone ) ; $ time = new DateTime ( $ datetime , $ timezone ) ; return $ time -> getTimestamp ( ) ; }
Converts a SQL `DATETIME` value to a unix seconds timestamp with an optional timezone.
Converts a SQL ` DATETIME ` value to a unix seconds timestamp with an optional timezone .