After I wrote this to the Twitter-support, I was encouraged to share
my finding here in this mailing-list.

During the last two weeks, I was designing a website where I
integrated your Twitter profile-widget.

I've changed a few parts of the design - and discovered the option to
show the Tweet-time "absolute" (something like Saturday, 07-16-2011
1:00 pm) instead of relative (like 5 minutes ago).

When I activated the option, I saw that Internet Explorer (Versions 7,
8 and 9) cannot show the tweets anymore.
I guess you have discovered this error yet, so you didn't describe the
option "dateformat" at the help-sites.

After many hours, I was able to identify the reason why IE cannot show
the absolute time.
Here your original code from "widget.js":

var absoluteTime = function(s) {
      var d = new Date(s);
      if (browser.ie) {
        d = Date.parse(s.replace(/( \+)/, ' UTC$1'));
      var ampm = '';
      var hour = function() {
        var h = d.getHours();
        if (h > 0 && h < 13) {
          ampm = 'am';
          return h;
        else if (h < 1) {
          ampm = 'am';
          return 12;
        else {
          ampm = 'pm';
          return h - 12;
      var minutes = d.getMinutes();
      var seconds = d.getSeconds();
      function getRest() {
        var today = new Date();
        if (today.getDate() != d.getDate() || today.getYear() !=
d.getYear() || today.getMonth() != d.getMonth()) {
          return ' - ' + months[d.getMonth()] + ' ' + d.getDate() + ',
' + d.getFullYear();
        else {
          return '';
      return hour + ':' + minutes + ampm + getRest();

In the forth line "d = Date.parse(s.replace(/( \+)/, ' UTC$1'));" the
time is converted in "milliseconds since 01-01-1970 UTC". The function
"getHours" in IE cannot interpret this time-format.
So you've got to insert after this line: "var d = new Date(d);"
Time is now converted in a format, that the IE-version of "getHours"
can understand.

The new code looks like this:

var absoluteTime = function(s) {
      var d = new Date(s);
      if (browser.ie) {
        var d = Date.parse(s.replace(/( \+)/," UTC$1"));
        var d = new Date(d);                    // here I've inserted the new 
      var ampm = '';
      var hour = function() {
        var h = d.getHours();
        if (h > 0 && h < 13) {
          ampm = 'am';
          return h;

You don't have to change anything anywhere else in the javascript! The
function for showing the relative time works by calculating the time-
differences - without getHours, getMinutes etc.

Now, every browser, including IE 7, 8 and 9, can show the tweets in
the profile-widget with absolute time!

I recommend to integrate the option "dateformat" in your "webform"
which creates the profile widget.
The other widgets could be improved the same way, as I guess they use
the same javascript.

I hope I could help you improving the Twitter-widget!
If my changes are used, it would be nice if you could insert something
like "//thanks to Stephan Schorn" in the javascript after the line I
changed (If you are allowed to do this). It would be great If my name
was somewhere in the sourcecode of Twitter-widgets ;-)

Best wishes,

Stephan Schorn

PS: I'm from Germany, please appologize if I made a linguistic mistake
here or there :-)

Have you visited the Developer Discussions feature on 
https://dev.twitter.com/discussions yet?

Twitter developer links:
Documentation and resources: https://dev.twitter.com/docs
API updates via Twitter: https://twitter.com/twitterapi

Unsubscribe or change your group membership settings: 

Reply via email to