Carbon – Convert Timezone

$time = Carbon::parse($value, 'UTC');
$time->setTimezone('Asia/Taipei');
$value = $time->toDateTimeString();

$now = Carbon::now('Asia/Taipei');

Reference:

if(!function_exists('local_time')){
	function local_time($time, $timezone){
		if(isset($time) == false || $time == false){
			return null;
		}
		
		$t = Carbon::parse($time);
        $t->setTimezone($timezone);
        return $t->toDateTimeString();
	}
}

if(!function_exists('to_utc')){
	function to_utc($time, $timezone){
		if(isset($time) == false || $time == false){
			return null;
		}
		
		$t = Carbon::parse($time, $timezone);
        $t->setTimezone('UTC');
        return $t->toDateTimeString();
	}
}