Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
How would I take a start/end dates user input, and convert it to US Pacific time, in ISO format?

I need to work a date object thru a specific set of circumstances.

  1. user is inputting a daterange, from/to.
  2. each date needs to be converted toISOString() because that's how it is in the DB.
  3. client wants the dateranges to hard convert to US Pacific time.

So when the user chooses from/to dates, the app is makes their chosen dates in US Pacific timezone, and then searches the db using ISO formatted dates.

I have this SE Post which gets me the timezone conversion, but in a non-iso format. Any attempts at deriving toISOString() molests the object right back to the device timezone.

I'm trying dayjs(), but it winds up being a bunch of extra steps, only to have the end result be molested to the device timezone.

How can I get the above series of events to unfold in the necessary order?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here is how you do it with dayjs

const dayjs = require("dayjs");
const utc = require("dayjs/plugin/utc");
const timezone = require("dayjs/plugin/timezone");

dayjs.extend(utc);
dayjs.extend(timezone);
let t = dayjs()
  .tz("America/Los_Angeles")
  .utc(true)
  .toISOString();

console.log(t);

Here is a list of all timezones https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

I personally live in europe, but when i execute this script it shows me the time in los angeles in ISO format

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!