jzaefferer/jquery-prettydate — Issue #2: Bad results when server and client timezones differ
Author: jzaefferer
Created: 2011-11-05 09:43:40+00:00
State: open

From comments on the plugin page:

> When the user and server are in differents timezones the result differs in hours (my server is in USA and I’m in Spain)

> I’m trying to get an independent-server-timezone response. To do that I set the server timezone to UTC with php.ini and set the diff at jquery.prettydate.js in this way:

> var dn = new Date();
> diff = (($.prettyDate.now().getTime() – date.getTime() – dn.getTimeZoneOffset()*6000) / 1000),

> but the result is the date without formating. What is wrong?

Someone tried tackling this, need to test this changes:

> I updated JÖRN’s 1.0.0 code to fix the issue that Jesus mentioned above (i.e., when your server date is in a different time zone than the user/client). For this I added a new, optional ‘now’ option that you can pass in that should hold the now time from the server.

> I have the updated code here:
> http://www.tehfaces.com/js/lib/prettydate/jquery.prettyDate.js

> Run a diff on this versus JÖRN’s 1.0.0 code to see what I changed.

> I also adjusted the code to output fuzzy dates up to 12 months.

> Ps. here a live example that shows example usage of the ‘now’ parameter. View source and look for ‘prettyDate(‘

> http://www.tehfaces.com/profile.teh?f=26