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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:48:35+00:00 2026-05-11T22:48:35+00:00

Let’s say I have a date that I can represent in a culture-invariant format

  • 0

Let’s say I have a date that I can represent in a culture-invariant format (ISO 8601).

I’ll pick July 6, 2009, 3:54 pm UTC time in Paris, a.k.a. 5:54 pm local time in Paris observing daylight savings.

2009-07-06T15:54:12.000+02:00

OK… is there any hidden gem of markup that will tell the browser to convert that string into a localized version of it?

The closest solution is using Javascript’s Date.prototype.toLocaleString(). It certainly does a good job, but it can be slow to iterate over a lot of dates, and it relies on Javascript.

Is there any HTML, CSS, XSLT, or otherwise semantic markup that a browser will recognize and automatically render the correct localized string?

Edit:

The method I am currently using is replacing the text of an HTML element with a localized string:

Starting with:

<span class="date">2009/07/06 15:54:12 GMT</span>

Using Javascript (with jQuery):

var dates = $("span.date", context);
// use for loop instead of .each() for speed
for(var i=0,len=dates.length; i < len; i++) {
    // parse the date
    var d = new Date(dates.eq(i).text());
    // set the text to the localized string
    dates.eq(i).text(d.toLocaleString());
}

From a practical point of view, it makes the text “flash” to the new value when the Javascript runs, and I don’t like it.

From a principles point of view, I don’t get why we need to do this – the browser should be able to localize standard things like currency, dates, numbers, as long as we mark it up as such.


A follow up question: Why do browsers/the Web not have such a simple feature – take a standard data item, and format it according to the client’s settings?

  • 1 1 Answer
  • 1 View
  • 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-05-11T22:48:35+00:00Added an answer on May 11, 2026 at 10:48 pm

    I use toLocaleString() on my site, and I’ve never had a problem with the speed of it. How are you getting the server date into the Date object? Parsing?

    I add a comment node right before I display the date as the server sees it. Inside the comment node is the date/time of that post as the number of milliseconds since epoch. In Rails, for example:

    <!--<%= post.created_at.to_i * 1000 %>-->
    

    If they have JS enabled, I use jQuery to grab those nodes, get the value of the comment, then:

    var date = new Date();
    date.setTime(msFromEpoch);
    // output date.toLocaleString()
    

    If they don’t have JS enabled, they can feel free to do the conversion in their head.

    If you’re trying to parse the ISO time, that may be the cause of your slowness. Also, how many dates are we talking?

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

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let's say I have a table with a Color column. Color can have various
Let's say that I have a SQLite database that I create in a separate
Let's say I have two text files that I need to extract data out
Let's say for a moment that I have the following module in python: class
Let's say you have a class library project that has any number of supplemental
Let's say I have an abstract parent class called shape, and that there are
Let say I have my view that I use it as a toggle button.
Let's say, I have an application that access(read/write) the file system(files inside application), Active
Let's say that I have a html form (actually I have an editor -

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.