How to create date in RFC3339 format in JavaScript

Datetime
By Jad Joubran · 
Last updated Feb 26, 2024
const date = new Date();

// RFC 3339 format
const rfc339 = date.toISOString();
2024-02-26T20:11:23.708Z