Answers for "javascript convert local date to utc timestamp"

1

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;
}
Posted by: Guest on June-23-2021
0

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)
Posted by: Guest on February-16-2022

Code answers related to "javascript convert local date to utc timestamp"

Code answers related to "Javascript"

Browse Popular Code Answers by Language