Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify what is current time #10

Closed
valodzka opened this issue May 12, 2010 · 10 comments
Closed

Allow to specify what is current time #10

valodzka opened this issue May 12, 2010 · 10 comments

Comments

@valodzka
Copy link

Currently it is hardcoded as browser current time, but it would be usefull to allow user specify that is current time (something like this http://gist.github.com/398904).

In my case it necessary because I have to display intervals like '2 seconds' ago and very often browser time is different from server time in couple of seconds. With this patch I can specify current time as server time and display correct intervals.

@rmm5t
Copy link
Owner

rmm5t commented May 12, 2010

Interesting. May I ask why you need such accurate intervals? Also, could you also supply the code that you would use to sync with the server time? Are you keeping a server timestamp from the time the page was rendered and then tracking against that? I'm interested, because if I add this feature, it might be nice to give an example as to why it was added.

Thanks,
Ryan

@valodzka
Copy link
Author

I have to display very frequently updated data - usually in interval from ten seconds to ten minutes (very rarely can be couple of hours), and one minute interval is too big. I added easily custom formating by replacing settings.strings.seconds, but with 'current time' I've got problem.

Here is how I've implemented it - http://gist.github.com/398928

@forrestfrazier
Copy link

I too have a similar concern. My server is in California but many of my users are on the East coast so when you insert a record into the database the timestamp is that of the server time (3 hours prior to current East coast time). This results in timeago always stating that a freshly inserted record was added "about 3 hours ago" instead of "less than a minute".

If there is a simple timezone fix that I'm missing please let me know. Otherwise perhaps this is something that needs to be addressed.

Thanks!

@rmm5t
Copy link
Owner

rmm5t commented Sep 13, 2010

forrestfrazier, Timeago timestamps are required to be in ISO8601 format, which includes a time zone. If you use the correct timestamp format, timeago should automatically work in all time zones. This reported ticket covers something different.

For more information, see Time zone designators for ISO8601

@forrestfrazier
Copy link

rmm5t, Thanks for calling that out. Since my datetime field doesn't have the timezone I had to play around with this a bit. Converted my timestamp to unix time, added the difference from my servers timezone to Zulu then output that in ISO8601

$unixtime = strtotime($dateTimeFromDatabase);
$ztime = $unixtime +420 * 60;
$guest_time = strftime("%Y-%m-%dT%H:%M:%SZ" , $ztime);
echo $guest_time;

Thanks again for the timeago, I love it.

@jk3us
Copy link

jk3us commented Apr 5, 2012

I don't know if anything ever happened with this request, but it's something I'd like to see as well.... It's not a huge deal, but our test server often has incorrect time (the ntp port is blocked, so we can't update it automoatically). And I often get things like "8 minutes ago" for things that just happened (should be "a few seconds ago"). If users computer time is a few minute off, this could cause confusion as well, so it would be nice to be able to say "current time is X" when the page loads and all calculations are based on that instead.

@m6w6
Copy link

m6w6 commented Jul 23, 2012

+1, I was just about to create a similar request.

@jacaetevha
Copy link

👍

This could be useful on a per-element basis as well. For instance, we have some elements that are representations of durations (within a known context) which we have to calculate server-side. But, if we could send the start and end time along to the client, timeago could do that calculation in the browser.

<time class="timeago" from="2013-03-22T10:25:56Z" datetime="2013-03-22T14:25:56Z" >past 4 hours</time>
$(document).ready ->
  $.timeago.settings.strings. prefixAgo = "past"
  $.timeago.settings.strings. suffixAgo = null
  $('.timeago').timeago()

@Laplandia
Copy link

That would be great. Otherwise people with wrong time see wrong results.

@AlexeyKosov
Copy link

Why is it still open?

I meant "unresolved" by "open" :(

@rmm5t rmm5t closed this as completed Sep 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants