在cesium中,默认时区为UTC。所以我想将UTC时区更改为SGT时区....你可以纠正我的错误,我的代码在下面找到.. SGT时区是GMT + 8 ..我想在时间轴和时钟视图上看到新加坡时间...我还希望将UTC替换为SGT。这是我的代码
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8">
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>SGT Timezone </title>
<script src="../Build/Cesium/Cesium.js"></script>
<style>
@import url(../Build/Cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
var viewer = new Cesium.Viewer('cesiumContainer');
//SST timezone
var TZcode = 'SGT';
//Construct a new Date
var UTCoffset = new Date();
//Return the timezone difference between UTC and Local Time:
UTCoffset = -UTCoffset.getTimezoneOffset();
//Construct a Julian Date
var UTCscratch = new Cesium.JulianDate();
// Date formatting to a global form
function localeDateTimeFormatter(datetime, viewModel, ignoredate) {
if(UTCoffset) datetime = Cesium.JulianDate.addMinutes(datetime, UTCoffset, UTCscratch);
var gregorianDT = Cesium.JulianDate.toGregorianDate(datetime), objDT;
if(ignoredate)
objDT = '';
else {
objDT = new Date(gregorianDT.year, gregorianDT.month-1, gregorianDT.day);
objDT = gregorianDT.day + ' ' + objDT.toLocaleString("en-us", { month: "short" }) + ' ' + gregorianDT.year;
if(viewModel || gregorianDT.hour+gregorianDT.minute === 0)
return objDT;
objDT += ' ';
}
return objDT + Cesium.sprintf("%02d:%02d:%02d "+TZcode, gregorianDT.hour, gregorianDT.minute, gregorianDT.second);
}
function localeTimeFormatter(time, viewModel) {
return localeDateTimeFormatter(time, viewModel, true);
}
viewer.animation.viewModel.dateFormatter = localeDateTimeFormatter;
viewer.animation.viewModel.timeFormatter = localeTimeFormatter;
viewer.timeline.makeLabel = function(time) { return localeDateTimeFormatter(time); }
document.querySelectorAll('.cesium-timeline-ticLabel').forEach(function(i) {
i.textContent = i.textContent.replace("UTC", "SGT");
});
</script>
</body>
</html>
默认时区是UTC,因此我想更改为GMT +8
的SGT时区