Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert timestamp to utc javascript

function utcformat(d){
    d= new Date(d);
    var tail= 'GMT', D= [d.getUTCFullYear(), d.getUTCMonth()+1, d.getUTCDate()],
    T= [d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds()];
    if(+T[0]> 12){
        T[0]-= 12;
        tail= ' pm '+tail;
    }
    else tail= ' am '+tail;
    var i= 3;
    while(i){
        --i;
        if(D[i]<10) D[i]= '0'+D[i];
        if(T[i]<10) T[i]= '0'+T[i];
    }
    return D.join('/')+' '+T.join(':')+ tail;
}
Comment

convert js date to utc

var UTCdate = new Date('4/29/2021 3:22:46 PM UTC');
console.log(UTCdate)
 // console.log(new Date('2020-1-1'+'UTC'));
// output 
// Thu Apr 29 2021 21:07:46 GMT+0545 (Nepal Time)
Comment

PREVIOUS NEXT
Code Example
Javascript :: react big calendar event color 
Javascript :: addeventlistener javascript 
Javascript :: js end of string 
Javascript :: javascript check if number 
Javascript :: javascript NEGATIVE_INFINITY 
Javascript :: lodash update object by id in array 
Javascript :: media queries generator script 
Javascript :: javascript remove multiple commas from string 
Javascript :: format date in javascript 
Javascript :: ** javascript 
Javascript :: json db 
Javascript :: node js send javascript 
Javascript :: get an element from outside of iframe jquery 
Javascript :: javascript regex exact match 
Javascript :: cypress get inut value 
Javascript :: upload file angular 
Javascript :: how to compare arrays in js 
Javascript :: cypress json schema vs code 
Javascript :: javascript convert date from mm/dd/yyyy to yyyymmdd 
Javascript :: object to map javascript 
Javascript :: execcommand javascript 
Javascript :: localecompare javascript 
Javascript :: create new connection in mongoose 
Javascript :: js add multiple element to document 
Javascript :: async function 
Javascript :: mongoose-encryption 
Javascript :: parseint javascript 
Javascript :: convert json to array 
Javascript :: json array in hidden field not coming 
Javascript :: add google analytics to react 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =