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

  • SEARCH
  • Home
  • 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 8957851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:05:12+00:00 2026-06-15T15:05:12+00:00

Is it possible to parse a localized DateTime string back to a proper DateTime

  • 0

Is it possible to parse a localized DateTime string back to a proper DateTime using native
Ruby or Rails methods?

I looked in i18n where I would expect this to be, since it holds the formats and locale, but I couldn’t find it.

I have a String: "za 18 mei 18:05" which is Dutch (:nl), in English it would be "Sa 18 May 6:15PM".The dateformat is: "%a %d %b %H:%M". I want the String to parse back to 2012-05-08T18:12:00+01:00.

Is there a possible way to get a DateTime from this? I have a large locale file for my Dutch translations and I can’t imagine I cannot use this to parse a format back to db format

  • 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-15T15:05:13+00:00Added an answer on June 15, 2026 at 3:05 pm

    You will need to manipulate your date strings a little bit, because they are not in English.

    Try this:

    nl = "vri 18 mei 18:05"
    dt = DateTime.strptime(nl.gsub(/vri|mei/, 'vri' => 'Fri', 'mei' => 'May'), "%a %d %b %H:%S")
    

    That is an example approach on how to replace ‘za’ with ‘Sat’ and ‘mei’ with ‘May’ before sending the string to strptime. You probably need to come up with a more elegant approach on replacing your original strings (writing a helper for example).

    Using the delocalize gem

    Alternatively, maybe you can try the gem delocalize:

    I18n.locale = :nl
    Delocalize::LocalizedDateTimeParser.parse("Vri 18 mei 18:02", DateTime)
    

    Make sure that you have the correct “nl.yml” in your config/locales folder.
    You can grab from here: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/nl.yml

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

Sidebar

Related Questions

Possible Duplicate: Parse C# string to DateTime I am facing a problem while converting
Is it possible to parse the Skype messages using Skype API? I would like
Possible Duplicate: Parse string to DateTime in C# I am getting date and time
Possible Duplicate: Parse Datetime string I'm trying to parse the following DateTime in C#:
Possible Duplicate: Parse string into argv/argc I'm trying to write a fake shell using
Is it possible to parse HTML (HTML/HTML5, not XHTML) pages using XPath and Qt
Possible Duplicate: How to parse JSON in JavaScript I have this JSON string: [{title:
It is possible to parse some information from the apk file using a tool
Is it possible to parse camel case string in to something more readable. for
Is it possible to parse YAML formatted strings with yaml-cpp? There isn't a YAML::Parser::Parser(std::string&)

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.