Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

utc to local time javascript

var UTCDate = '6/29/2011 4:52:48 PM';
var localDate = new Date(UTCDate + ' UTC');
Comment

js UTC to local timezone

// This would come from the server.
// Also, this whole block could probably be made into an mktime function.
// All very bare here for quick grasping.
d = new Date();
d.setUTCFullYear(2004);
d.setUTCMonth(1);
d.setUTCDate(29);
d.setUTCHours(2);
d.setUTCMinutes(45);
d.setUTCSeconds(26);

console.log(d);                        // -> Sat Feb 28 2004 23:45:26 GMT-0300 (BRT)
console.log(d.toLocaleString());       // -> Sat Feb 28 23:45:26 2004
console.log(d.toLocaleDateString());   // -> 02/28/2004
console.log(d.toLocaleTimeString());   // -> 23:45:26
 Run code snippet
Comment

javascript convert utc to local time

var date = new Date('6/29/2011 4:52:48 PM UTC');
date.toString() // "Wed Jun 29 2011 09:52:48 GMT-0700 (PDT)"
Comment

PREVIOUS NEXT
Code Example
Javascript :: path module js 
Javascript :: react 18 rendering twice 
Javascript :: array list in javascript 
Javascript :: how to make alert in javascript 
Javascript :: javascript get cursor position without event 
Javascript :: javascript get second last element of array 
Javascript :: js highest number in array 
Javascript :: moment time from now 
Javascript :: redux toolkit how to set empty initial state 
Javascript :: razorpay node sdk 
Javascript :: javascript array clear 
Javascript :: js iife 
Javascript :: plotly express bar graph 
Javascript :: how to print a array js 
Javascript :: kendo jquery grid refresh data 
Javascript :: types for parameter destructuring 
Javascript :: gatsby tailwind 
Javascript :: anguler test submit form 
Javascript :: javascript set max length of string 
Javascript :: javascript slice string from character 
Javascript :: display for sometime only session flash message in laravel with javascript 
Javascript :: discord.js make channel private 
Javascript :: change object in array in state 
Javascript :: listing range in javascript 
Javascript :: javascript print to pdf 
Javascript :: next js redirect if not logged in 
Javascript :: parsley validation checkbox 
Javascript :: react code 
Javascript :: useEffect : react 
Javascript :: filter an array 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =