Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:57:11+00:00 2026-06-12T07:57:11+00:00

Unless I use the .toLocaleDateString() method, the function below returns a date that is

  • 0

Unless I use the .toLocaleDateString() method, the function below returns a date that is one day less than it should be. Am I doing something wrong or is this a defect?

    function myDate() {
  var sDate = '05/10/2012';
  var parts = sDate.split('/');
  var d = new Date( parts[2], parts[1]-1, parts[0]);
  Logger.log(d);
  Logger.log(d.toLocaleDateString());
};

The Logger returns:

Thu Oct 04 16:00:00 PDT 2012

05 October 2012 00:00:00 BST

I’m in the UK, hence the UK date format. I’ve checked that my project properties have the time zone set to “(GMT+00:00) London” so why does the Logger show the first date in PDT? Is that the reason for the wrong date? I’ve reproduced the problem in a stand-alone project. Here’s a link to it.

I wanted to convert the string variable into a date object in order to do some date math so having to convert back to a string with .toLocaleDateString() method isn’t helpful.

I’ve checked for consistence, thinking perhaps I could work around it, by testing with other dates. Bizarrely, if I change the value of sDate to anything between 01/01/2012 & 04/03/2012 it returns accurately. From 05/03/2012 onwards it drops a day. With 2013 dates, it returns correctly until 29/04/2013 when it starts dropping a day again. So it’s not consistent. It seems similar to the problem reported here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:57:12+00:00Added an answer on June 12, 2026 at 7:57 am

    The logger always logs dates in PDT. It’s the same instance of time, just represented a different way. You are seeing that + differences in daylight savings time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unless I am doing something wrong, the way I am supposed to use ConfigurationSection,
I know that you can't do cross-domain ajax requests unless you use a 'proxy'
I've noticed, that unless I use a cellspacing attribute set to 0px on my
Unless I'm mistaken, creating a function in Python works like this: def my_func(param1, param2):
The code below works unless p.School.SchoolName turns out to be null, in which case
My view is that unless you need to change the basic structure of the
I'm testing a richfaces application with selenium. It works fine, unless I use reRender
I am building a one page site that uses javascript to navigate vertically and
I made this javascript method that I altered from an existing script that I
Passing Value Type parameters to functions in c# is by value unless you use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.