Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript set date to timezone

var d = new Date("2020-04-13T00:00:00.000+08:00"); /* midnight in China on April 13th */
d.toLocaleString('en-US', { timeZone: 'America/New_York' });
//=> "4/12/2020, 12:00:00 PM"
// (midnight in China on April 13th is noon in New York on April 12th)
Comment

Parse date without timezone javascript

let s = "2005-07-08T11:22:33+0000";
let d = new Date(Date.parse(s));

// this logs for me 
// "Fri Jul 08 2005 13:22:33 GMT+0200 (Central European Summer Time)" 
// and something else for you

console.log(d.toString()) 

// this logs
// Fri, 08 Jul 2005 11:22:33 GMT
// for everyone

console.log(d.toUTCString())
Comment

javascript parse date in current timezone

/*  @param {string} s - an ISO 8001 format date and time string
**                      with all components, e.g. 2015-11-24T19:40:00
**  @returns {Date} - Date instance from parsing the string. May be NaN.
*/
function parseISOLocal(s) {
  var b = s.split(/D/);
  return new Date(b[0], b[1]-1, b[2], b[3], b[4], b[5]);
}

document.write(parseISOLocal('2015-11-24T19:40:00'));
Comment

PREVIOUS NEXT
Code Example
Javascript :: cut and paste element js 
Javascript :: javascript ISO Date Formats 
Javascript :: javascript heap out of memory error 
Javascript :: chrome extension onclick not working 
Javascript :: set date to input date 
Javascript :: optional chaining in javascript 
Javascript :: math from string js 
Javascript :: js if condition 
Javascript :: javascript mutation observer 
Javascript :: react native update state object inside object 
Javascript :: scroll btn 
Javascript :: date range npm 
Javascript :: react useEffect life cycle 
Javascript :: bin to bit string javascript 
Javascript :: for in loop javascript 
Javascript :: datatable add filter dropdown 
Javascript :: javscript assert 
Javascript :: express mysql sessions 
Javascript :: streami node js 
Javascript :: js add zeros before number 
Javascript :: get string before specific character nodejs 
Javascript :: format phone number javascript 
Javascript :: shadow react native generator 
Javascript :: .includes meaning in javascript 
Javascript :: Sorting Data Accessor 
Javascript :: express proxy 
Javascript :: javascript async await not waiting 
Javascript :: vb net textbox regular expression 
Javascript :: apollo uselazyquery oncompleted 
Javascript :: angular print html 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =