I'm using javascript only (not allowed to use any 3rd party js), and i want to retrieve current datetime in UTC+7 with a format like this yyyy-MM-ddTHH:mm:ss.SSSTZD
for example:
2019-05-14T16:36:20.000+07:00
I'm using javascript only (not allowed to use any 3rd party js), and i want to retrieve current datetime in UTC+7 with a format like this yyyy-MM-ddTHH:mm:ss.SSSTZD
for example:
2019-05-14T16:36:20.000+07:00
If you use momentjs you can accomplish that like so:
console.log(moment().utcOffset(7).format("YYYY-MM-DDTHH:mm:ss.SSSZ"))
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
enter code here
let date = new Date();
console.log('UTC' + (-date.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(date.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(date.getTimezoneOffset() / 60)) + ':00');