Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

formatting time for ical export

const date = "July 1, 2022";
const time = "1:30 PM";

function calendarTimeFormat(date) {
    const year = Intl.DateTimeFormat('en', { year: 'numeric', timeZone: 'utc' }).format(date);
    const month = Intl.DateTimeFormat('en', { month: '2-digit', timeZone: 'utc' }).format(date);
    const day = Intl.DateTimeFormat('en', { day: '2-digit', timeZone: 'utc' }).format(date);
    const hour = Intl.DateTimeFormat('en', { hour: '2-digit', timeZone: 'utc', hour12: false }).format(date).split(' ')[0];
    const minute = Intl.DateTimeFormat('en', { minute: '2-digit', timeZone: 'utc' }).format(date).split(' ')[0];
    return year + month + day + "T" + hour + minute + "00Z";
}

const d = Date.parse(`${date} ${time}`);
console.log(calendarTimeFormat(d);
Comment

PREVIOUS NEXT
Code Example
Javascript :: rpushx redis 
Javascript :: javascript enum includes value 
Javascript :: filtering to check that a string is contained in the object in js 
Javascript :: React clock via props 
Javascript :: Bootstrap 5 data attributes different from Bootstrap 4 
Javascript :: Is It Negative Zero (-0)? js 
Javascript :: execute only once on multiple clicks javascript 
Javascript :: Priority Queue Element 
Javascript :: req.session undefined express node js 
Javascript :: nodejs split array into chunks 
Javascript :: js to jsx 
Javascript :: remove element 
Javascript :: react word cload 
Javascript :: react-bootstrap-sweetalert is not running 
Javascript :: express-roteamento 
Javascript :: multply js 
Javascript :: buiding react project 
Javascript :: useMediaquery hook react 
Javascript :: Plumsail set form lookup field value on form load 
Javascript :: angular resolver with parameters 
Javascript :: javascript folder array randomizer 
Javascript :: Javascript shows me TypeError saying my variable is undefined 
Javascript :: How to create a table with indents from nested JSON in angularjs 
Javascript :: Angularjs $on called twice 
Javascript :: how to use recursive function to select the parent in a tree array using angulat ui tree 
Javascript :: how to edit data retrieval using jsp 
Javascript :: gradient of a function 
Javascript :: error first callback in node js 
Javascript :: useEffect in React 18 in strictmode 
Javascript :: how can do i open the select tag using keyboard event using javascript site:stackoverflow.com 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =