Support Forum

  • Page:
  • 1

Solution: Display Date instead of "... days ago"

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Just in case somebody is interested in the solution I figured out today for displaying the creation date of tweets instead of the relative date.

Fast solution:
In jquery.tweet.js just replace the complete function rest_relative_time with this:

function rest_relative_time(time_value) {
time_value = time_value.replace(/(\+[0-9]{4}\s)/ig,"");
var values = time_value.split(" ");
var parsed_date = new Date();
parsed_date.setTime(Date.parse(time_value));
var months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug','Sep', 'Oct', 'Nov', 'Dec');
var postedAt = '';
var m = parsed_date.getMonth();
var h = parsed_date.getHours();
h = (h > 12) ? h-12 : h;
postedAt = months[m];
postedAt += " "+ parsed_date.getDate();
postedAt += ", "+ parsed_date.getFullYear();
postedAt += " "+ h;
postedAt += ":"+ parsed_date.getMinutes();
postedAt += (parsed_date.getHours() < 12) ? " am" : " pm";
return postedAt;
}

Cleaner solution: Give the function a new name and replace "rest_relative_time" it in the <span class="tweetDate"> line.

p.s. remember, this code modification will be lost if and when there is an offered upgrade to jTweet that you install...
  • Zielgestalt's Avatar
  • Zielgestalt
  • Free Extensions
  • 1 posts
  • Karma: 0
Last Edit: 9 years 4 months ago by Zielgestalt. Reason: Issue in IE8: replaced: time_value = time_value.replace(/ +[d]{4}/, ""); new code: time_value = time_value.replace(/(\+[0-9]{4}\s)/ig,"");
The administrator has disabled public write access.
Cool thanks for posting this - Ill make it a sticky as it might help someone else looking for the same customisation.

Cheers Anthony
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Happy Campers