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 7835295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:35:14+00:00 2026-06-02T13:35:14+00:00

Calling Date.today in Ruby returns the current date. However, what timezone is it in?

  • 0

Calling Date.today in Ruby returns the current date. However, what timezone is it in? I assume UTC, but I want to make sure. The documentation doesn’t state either way.

  • 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-02T13:35:17+00:00Added an answer on June 2, 2026 at 1:35 pm

    TL;DR: Date.today uses the system’s local time zone. If you require it be in UTC, instead get the date from a UTC time, e.g. Time.now.utc.to_date.


    Dates do not have timezones, since they don’t represent a time.

    That said, as for how it calculates the current day, let’s look at this extract from the code for Date.today:

    time_t t;
    struct tm tm;
    // ...
    if (time(&t) == -1)
      rb_sys_fail("time");
    if (!localtime_r(&t, &tm))
      rb_sys_fail("localtime");
    

    It then proceeds to use use tm to create the Date object. Since tm contains the system’s local time using localtime(), Date.today therefore uses the system’s local time, not UTC.


    You can always use Time#utc on any Time convert it in-place to UTC, or Time#getutc to return a new equivalent Time object in UTC. You could then call Time#to_date on that to get a Date. So: some_time.getutc.to_date.

    If you’re using ActiveSupport’s time zone support (included with Rails), note that it is completely separate from Ruby’s time constructors and does not affect them (i.e. it does not change how Time.now or Date.today work). See also ActiveSupport extensions to Time.

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

Sidebar

Related Questions

Calling getActionBar returns null . This has been frequently reported so I've made sure
Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need
Calling the ajax called URL works well without ajax eg. http://localhost/ci/controller/method/param_value . But using
I am calling my database which contains a datetime datatype. The date looks like
I need to compare two date in javascript. In my code I am calling
Im not quite sure what the term is, I have been calling it Split
I'm trying to update my custom ArrayAdapter, but after calling updateListArray getView is called
On the leap year, [NSDate date] returns 2012-03-01 HH:MM:SS +TTTT . On stackoverflow I've
I have a datetime field in MySQL which I access through calling result.getString('date'), now
I want to store a password in my app to encrypt the installation date

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.