I believe d.toDateString() will output the format you're looking for.

var d = new Date();
d.setTime(1432851021000);
d.toDateString(); // outputs to "Thu May 28 2015"
d.toGMTString(); //outputs to "Thu, 28 May 2015 22:10:21 GMT"

Or even d.toLocaleString() "5/28/2015, 6:10:21 PM"

There are lots of methods available to Date()

Answer from gautsch on Stack Overflow
🌐
Reddit
reddit.com › r/learnjavascript › how to remove timezone ?
r/learnjavascript on Reddit: How to remove timezone ?
May 7, 2025 -

Hello,

I have a datepicker and it shows me example this:

Sun May 04 2025 15:30:00 GMT+0200 (Mitteleuropäische Sommerzeit)

if I send it to my backend with fetch in the network list it shows this:

2025-05-04T13:30:00

two hours different but I want to remove the timezone how I do it ?

let startTime = picker.value();

const send = async () => { 
  const res = await fetch('https://backend...', {
     method: 'POST',
  headers: {
    'Content-type': 'application/json; charset=UTF-8',
  },
  body: JSON.stringify({
    startTime
  }),
})
.....
},

I tried this

startTime.toISOString().slice(0, 19)

but not works it shows correctly in console.log but after send to my backend in the network tab in chrome it shows this:

2025-05-04T13:30:00

but it should be 15:30

🌐
Reddit
reddit.com › r/learnjavascript › question regarding dates and time zones
r/learnjavascript on Reddit: Question regarding dates and time zones
August 10, 2023 -

We are trying to add times to our dates in an older app and the dates were almost always stored as partially formed ISO strings. Not a hard rule since times were never used before.

Now I need to start displaying the times with the dates and allowing the user to alter the times on the front end.

Example: we get a date ISO string from the backend as 2008-08-15T00:00:00.

When I create a Date object from it, I get the date in my local time zone (GMT-0600). In this example, Fri, August 15, 2008 00:00:00 (GMT-0600).

Then later when the edit form is submitted with no change to the day or time, I convert the Date object to an ISO string and strip the milliseconds and time zone code to keep it consistent with the current format in the database. In this example it returns 2008-08-15T06:00:00 to the backend.

Notice the time was provided as 00:00:00 but after parsing it and then converting to an ISO string, I've now added 6 hours to the time and am returning 06:00:00.

I am thinking I could convert it to GMT-0000 before converting to an ISO string but I'm not sure if that is the cleanest solution. Has anyone else had a similar scenario and what would you suggest to do to make this work (that doesn't include altering all the dates in the DB, we're planning for that down the road)?

Top answer
1 of 5
2
Had the same issue, our DB and servers are set to UTC but in browser they're set to user timezone, which JS always assumes. To ensure JS knows what timezone the time you're providing is in, append it to the end of your timestamp. For example: new Date(myTimestamp + " UTC"). Yep, looks horrific but is a valid and recommended solution apparently. Welcome to JavaScript! Also be sure to check Safari support as the wah Safari handles dates is very messed up.
2 of 5
2
new Date() defaults to using the local timezone pulled from the browser which is pulled from the OS. When dealing with times the best way to handle is to store dates in ISO or UTC, or if you want to store local times, store the IANA timezone string. ('America/Chicago' or 'America/Sao_Paulo') and always track the users locale string ('en-US', 'pt-BR) Then explicitly use both locale and IANA. So when you display on the frontend you can use something like this: new Date().toLocaleString( 'en-US', { dateStyle: 'medium', timeStyle: 'medium', timeZone: 'America/Chicago' } ) new Date() in the browser assumes UTC but toString converts to local. Give it a date without time new Date('2022-02-22') and it will convert FROM UTC TO your local standard time. The ASSUMPTION is this string comes from standard server time. date-fns and Luxon do the opposite. They assume '2022-02-22' is local time. parseISO('2022-02-22') without specifying timezone converts FROM local TO local. That's why they feel more intuitive if you're not paying attention. I HIGHLY encourage always using toLocaleString for formatting, even if you're using Luxon or date-fns. Don't give your users these manually formatted "MM/yyyy" things. Locale string formats are locale aware (sometimes dates go before moths), lowercase months when they're supposed to be lowercase, and handle translations. (Yeah! Translations!) So months days, weekdays, etc. will be translated. And for Spanish speaking countries they will use more standard things like 'de' which translates to 'of'. Aug 11, 2023, 2:32:00 PM 11 de ago. de 2023, 14:32:00
🌐
DEV Community
dev.to › shubhampatilsd › removing-timezones-from-dates-in-javascript-46ah
Removing Timezones from Dates in Javascript - DEV Community
April 23, 2023 - For your trip, if you travel to the island of Oahu, Hawaii, you would be under the HST timezone (Hawaiian Standard Time), which is 3 hours behind PST (Pacific Standard Time). The event that you scheduled for 4:30 PM would now show up at 1:30 PM for you. This would occur because JavaScript automatically adjusts UTC dates for you based on your current timezone.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-date-remove-time
Remove the Time or Time Zone from a Date in JavaScript | bobbyhadz
There is nothing that relates to the time in the string, so the hours, minutes, seconds and milliseconds get set to 0 in the newly created Date object. There are multiple ways to remove the local time zone from a date:
🌐
CopyProgramming
copyprogramming.com › howto › how-to-remove-timezone-from-date-in-javascript
How to Remove Timezone from Date in JavaScript: Complete Guide for 2025
December 27, 2025 - This native JavaScript function converts your date to an ISO 8601 format string in UTC, completely removing timezone offset information.
🌐
GitHub
github.com › moment › moment › issues › 2788
Remove timezone from a moment.js object · Issue #2788 · moment/moment
December 4, 2015 - I'm using datetimepicker.js and its date function returns a moment.js object. It does so with the local UTC offset in it and my original date has a different offset. ... Note how I removed the +01 offset at the end.
Author   alvarotrigo
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-create-date-without-timezone
How to Create a Date without Timezone in JavaScript | bobbyhadz
To create a Date without the timezone, we called the toISOString() method on the Date object and removed the character Z from the ISO string.
Find elsewhere
🌐
Reddit
reddit.com › r/react › [deleted by user]
How the hell do you store a DATE without offset : r/react
July 20, 2024 - Nothing stops you to store it at the day precision in your database but you will need to cast it again when creating a JavaScript time. ... You can still store such a date in UTC, just store it with a time of 00:00 in UTC. Convert it back to any local timezone, and you will always end up with ...
🌐
Reddit
reddit.com › r/javascript › js dates are about to be fixed
r/javascript on Reddit: JS Dates Are About to Be Fixed
August 26, 2024 - You can see some of the documentation about that here, where they talk about introducing new extensions to the traditional ISO string that include timezone info (not just offset, but the full timezone and calendar information). Finally, the big difference is that if you use Temporal for the easy stuff that can be done with Date anyway, then it's easier to get things right when the complicated stuff shows up. I've seen too much wild manipulation done on Date objects to be comfortable saying that Date should ever be the go-to type. ... That's not quite true. It's also perfectly fine if the timestamp was from a user in a different timezone, being displayed in the current user's timezone, and the actual correct moment is what matters.
🌐
Reddit
reddit.com › r/node › how do you possibly deal with timezones accuratly?
r/node on Reddit: How do you possibly deal with timezones accuratly?
April 10, 2025 -

My most frustrating programming woes ever have been managing different timezones. How do you all handle these situations effectively?

In my app, I have data sources from many places. Then I aggregate that data in terms like month-to-date, today, etc. However, these all have different definitions depending what timezone the user is in. So when someone queries the API from the frontend, how do you make sure their month-to-date makes the most sense to their timezones?

I am currently using Luxon to do transformations like start of month, and end of month for database conversions. However Luxon on the server will do the start and end based on the server timezone. I could set it to another, but then I would have to report on specifically what that is. I can't do simple offsets, as I would still have to account for daylight savings etc. Even with packages this feels like insanity.

🌐
Reddit
reddit.com › r/javascript › date and time in javascript
r/javascript on Reddit: Date and time in JavaScript
January 4, 2018 - What we ended up doing, which works but is super hacky to me, is that we store all times as YYYY-MM-DDTHH:MM:SS with no timezone data; the browser loads this assuming that it's in the user's timezone and appends their tz offset. While they're working on the dates, everything is assumed to be in their TZ, and then when we save it we strip the tz offset from the end of the datetime string we send up.
🌐
Reddit
reddit.com › r/learnjavascript › date object and timezones stuff
r/learnjavascript on Reddit: Date object and timezones stuff
February 6, 2024 -

when I set a date using a calander libary and save it in my localstorage as date.toISOString().split("T")[0] and after reloading the page, I retrieve from the localstorage and set in my local variable with new Date(date), it sets the time 1 day backward. I'm guessing its because the timezone i'm using is US and since US is 7 hours behind UTC, so new Date() treats the argument as a UTC time and converts it into a local time?, how do I configure it to give me the exact date I stored in my localstorage?

🌐
Reddit
reddit.com › r/askprogramming › what's are best practices when dealing with dates, without time-of-day?
r/AskProgramming on Reddit: What's are best practices when dealing with dates, without time-of-day?
May 19, 2022 -

What is best practice when dealing with date values without time, in JavaScript? My concern is subtle off-by-one bugs caused by local Time Zone (TZ) offset (e.g. +5 hours), when doing date math.

JavaScript's built-in Date type represents a date and time not just the date. Internal representation is an integer of microseconds since 1970-01-01 00:00:00 UTC. Other languages, like Python, have separate Date and DateTime types. Java 8 introduced LocalDate.

You also have things like: new Date('5/18/2020') is local TZ (in US), but new Date('2022-05-18') is UTC. Same with Date.parse(string). And the time zone on most servers in UTC, whereas on the browser side the time zone will vary.

The date values will be used for simple date math in code and will be stored in a SQL database.

Possibilities:

  1. Use the an alternate type like integer value, of milliseconds or days (since 1970-01-01), or string in YYYYMMDD format.

  2. This was combined with #1

  3. Use Date ignoring time (as 00:00 local TZ). Convert from/to UTC when reading/writing to database

  4. Use Date with time as 00:00 UTC. Have to be careful not to mix with Date values in local TZ (e.g. now = new Date())

  5. Use Date in local TZ, but convert to UTC when read/writing to database. This is a variant of #3.

  6. Create a LocalDate class that enforces midnight.

  7. Use a library. js-joda has LocalDate.

I am leaning towards #3 and #6. Some code I am writing:

class LocalDate extends Date {
  // Error if time isn't midnight local TZ
  // Do not accept string in ISO format
  constructor(date?: Date|number|string)

  // Convert to 00:00 UTC
  // To be used before write to database
  toUtc(): Date

  // Only return date.  Also affects toJSON()
  toISOString(): string

  // Returns today's date at 00:00 Local TZ
  static today(): LocalDate
  // Set time to midnight local TZ, without error check.
  static fromDateTime(date: Date|number): LocalDate
  // Convert to local TZ.  Error if not 00:00 UTC.
  static fromUtc(date: Date|number): LocalDate
}

UPDATE:

Various edits.

🌐
Reddit
reddit.com › r/learnjavascript › remove timezones and daylight saving time from date
r/learnjavascript on Reddit: Remove Timezones and Daylight Saving Time from Date
June 3, 2016 -

Hi, I have been working on a little project where I create object keys from date timestamps.

The problem that is arising is that at March 24th - 25th when DST happens the values are no longer correct. How can I use a "dumb" date / calendar that does not have DST or Timezones?

const MILLISECONDS_IN_DAY = 86400000;

const FROM_MS = dateFns.startOfDay( from ).getTime();
const TO_MS = dateFns.startOfDay( to ).getTime();
const DIFF_IN_MS_BETWEEN_FROM_AND_TO = ( TO_MS - FROM_MS );
const MAX_MS = FROM_MS + DIFF_IN_MS_BETWEEN_FROM_AND_TO;

const day_bookings = {};

for ( let day_index = FROM_MS; day_index < MAX_MS; day_index += MILLISECONDS_IN_DAY ) {
    const current_day = dateFns.startOfDay( day_index );

    console.log( current_day );
    console.log( day_index, current_day.getTime() );
    console.log( day_index === current_day.getTime() );
    
    // won't be able to access later if timezone and/or DST is making the key unpredictable for me...
    day_bookings[ day_index ] = new DayBooking( current_day ); 

    ...

March 25th

Sun Mar 25 2018 00:00:00 GMT+0100 (Central European Standard Time)
1521932400000 1521932400000
true

March 26th

Mon Mar 26 2018 00:00:00 GMT+0200 (Central European Summer Time)
1522018800000 1522015200000
false
🌐
Medium
toastui.medium.com › handling-time-zone-in-javascript-547e67aa842d
Handling Time Zone in JavaScript. Recently, I worked on a task of adding… | by TOAST UI | Medium
August 30, 2019 - Like I said several times, JavaScript does not allow manual change of local time zone. The only solution to this is adding or removing the value of the offset from the date provided that you already know the value of the time zone’s offset.
🌐
TutorialsPoint
tutorialspoint.com › how-to-remove-time-from-date-typescript
How to remove Time from Date TypeScript?
The JavaScript code will produce the following output ? ... One benefit of using this method is its simplicity. The date in the desired format can be easily retrieved by calling the toLocaleDateString() method on a Date object.
🌐
Ursahealth
ursahealth.com › new-insights › dates-and-timezones-in-javascript
Working with dates and timezones in JavaScript: a survival guide
May 4, 2021 - To render this date with confidence we have to actually change the universal time that the JavaScript object is trying to represent. Remember that getTime() converts the date to an integer representing milliseconds. If we back out the server timezone offset, and apply the local timezone offset, we will have shifted the universal time from the server’s midnight to the user’s local midnight.