我有来自php的以下json对象日期,我需要在用户时区以dd / mm / YYYY HH显示日期:mn格式:
{ "date": "2018-05-01 22:06:01.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
答案 0 :(得分:1)
您可以使用moment.js
优秀的库来处理日期
https://momentjs.com/timezone/
let json = { "date": "2018-05-01 22:06:01.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
};
let date = moment.tz(json.date, json.timezone);
console.log(date);

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.17/moment-timezone-with-data.min.js"></script>
&#13;