📜  碳将日期时区从 1 更改为 UTC - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:13.448000             🧑  作者: Mango

代码示例1
Carbon::createFromFormat('Y-m-d H:i:s', $some_date, 'UTC')
    ->setTimezone('America/Los_Angeles')
    
// First, you set the timezone you initially have, 
// so if you store your date in the database as UTC, 
// then set the default timezone to UTC, 
// then use ->setTimeZone('Valid/Timezone') 
// to make the change from what you'v had to the new timezone.