I have tried using
console.log(new Date().toISOString())
this gives output like 2020-08-08T03:20:14.362Z
how to get 2020-08-08T03:20:14.362+00:00 as output
Try this:
function format(date) {
return date.split('Z')[0]+'+00:00';
}
console.log(format(new Date().toISOString()));
Using date-fns
, format()
method
const res = dateFns.format(new Date()) console.log(res)
<script src="https://cdnjs.cloudflare.com/ajax/libs/date-fns/1.28.5/date_fns.min.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.