0

Hi
I have developed an website with drupal 7.10. I want this should be in bengali language. everything is ok but problem with numerical system.
for example: date,time,points etc.

Now I have decided to add java code at the bottom of the theme. so that after loading the page javascript with replace those text.
This replacement should be limited to some span not in all document.

I have this as below code in the document

<span class="submitted">মঙ্গলবার, 12/20/2011 - 07:10 <a class="username" title="সদস্য জিবনবৃত্তান্ত দেখ" href="/user/4">afshalur</a></span>

Now I want that 12/20/2011-07:10 will be ১২/২০/২০১১-৭:১০ with the help of javascript. Is it possible?

thank u

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Fest3er
0

Look up JS' Date object and its Date.toLocaleString() method.

You probably need id="..." or name="..." to identify the tags you want to change.

Then you need something like:

function dateToLocale(inDate) {
  var outDate = new Date($inDate);
  return outDate.toLocaleString(outDate);
}
...
// Get a tag that may contain a date/time string
elem = getElementById("myID");

// Replace all occurrences of date/time in this element with local representation strings
elem.innerHTML = elem.innerHTML.replace(/[0-3][0-9]\/[0-3][0-9]\/[0-9][0-9][0-9][0-9] - [0-2][0-9]:[0-5][0-9]/g, dateToLocale());

(Concept gleaned from Flanagan's JavaScript book.)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.