Skip to content

Commit

Permalink
优化:非 UTC+8 时区转换
Browse files Browse the repository at this point in the history
  • Loading branch information
taksssss committed Sep 6, 2024
1 parent 165a2fa commit 3c140e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ PHP 实现的 EPG(电子节目指南)服务端, `Docker` 部署,自带
- [x] 支持繁体频道匹配
- [x] 仅保存指定频道列表节目单
- [x] 导入/导出配置
- [ ] 频道指定 `EPG`
- [x] 频道指定 `EPG`

## 部署步骤 🚀

Expand Down
2 changes: 2 additions & 0 deletions epg/config_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"\\s"
],
"channel_mappings": {
"CCTV4AME": "CCTV4美洲",
"CCTV4EUO": "CCTV4欧洲",
"CGTN Documentary, CGTN档案, CGTN记录": "CGTN纪录",
"regex:\/^CCTV[-\\s]*(\\d{1,2}(\\s*P(LUS)?|[K\\+])?)(?![\\s-]*(美洲|欧洲)).*\/i": "CCTV$1"
}
Expand Down
7 changes: 4 additions & 3 deletions epg/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ function deleteOldData($db, $keep_days, &$log_messages) {
}
}

// 格式化时间函数
// 格式化时间函数,同时转化为 UTC+8 时间
function getFormatTime($time) {
$date = DateTime::createFromFormat('YmdHis O', $time)->setTimezone(new DateTimeZone('+0800'));
return [
'date' => substr($time, 0, 4) . '-' . substr($time, 4, 2) . '-' . substr($time, 6, 2),
'time' => strlen($time) >= 12 ? substr($time, 8, 2) . ':' . substr($time, 10, 2) : ''
'date' => $date->format('Y-m-d'),
'time' => $date->format('H:i')
];
}

Expand Down

0 comments on commit 3c140e4

Please sign in to comment.