|
If I have a time variable in Ruby, how could I say that it refers to an event that happened one of the following:
"x minutes ago" or "x hours ago" or "x days ago"
Obviously if something happened 2 days ago, I would not want to say it happened such-and...
Started by Kenneth Johns on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
In seconds if (elapsed < 60) puts "#{elapsed} seconds ago" elsif (elapsed < 60*60) puts "#{elapsed/60} minutes ago" end
If you are on rails:
time_ago_in_words
Here's the language agnostic version * 3652425 / 10000 def when....
|
|
20 seasons ago, only Elizabeth Vale, Parafield Gardens and Elizabeth Downs still competing in SAASL Sunday Division 1.
Bert Fuda (then a spritely 22 y.o.) possibly the only player listed still competing in the this Division.
.
Started by To Mati on
, 30 posts
by 18 people.
Answer Snippets (Read the full thread at footballnews):
What happened to the clubs that were playing then anyone know? Did... .
Swannsong,
I think the things you have put on here are awesome, the State Team photo and now this, I know I find it very interesting, look at the names mentioned on the list from 1988 .
|
|
Can anyone tell me how I can display a status message like "12 seconds ago" or "5 minutes ago" etc in a web page?
Started by Niyaz on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Here is the php code for the same:
function time_since($since) { $chunks = array( array(60 * 60 * 24 * 365 , 'year'), array(60 * 60 * 24 * 30 , 'month'), array(60 * 60 * 24 * 7, 'week'), array(60 * 60 * 24 , 'day'), array(60 * 60 , 'hour'), array(60 ,... .
|
Ask your Facebook Friends
|
Given a time, how can I find the time one month ago.
Started by steven on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Check out the documentation here: http://ca3.php.net/strtotime
strtotime( '-1 month', $timestamp );
http://php.net/manual/en/function.strtotime.php
<?php $date = new DateTime("18-July-2008 16:30:30"); echo... .
In php you can use strtotime("-1 month").
|
|
How would I get the date 180 days ago using C#?
Thanks
Started by Jamie on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
DateTime.Now.AddDays(-180)
DateTime oneEightyAgo = DateTime.Today.AddDays(-180);
DateTime....
DateTime.Now.AddDays(-180)
EDIT:
DateTime day180 = Date.Now.AddDays(-180);
It's important to put it into a separate variable otherwise the value will be lost .
|
|
I'm using 'time_ago_in_words' function in a view, and I need to test the output in the FunctionalTest.
But the test can not see 'time_ago_in_words' helper function.
What should I do in order to use these helper methods from FunctionalTests?
Started by Raiden on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
And that's it, from the test console:
>> time_ago_in_words(3.minutes.from_now) NoMethodError: undefined method `time_ago_in_words' for #<Object:0x3b0724> from (irb):4 from /Users/blinq/.rvm; Object >> time_ago_....
|
|
I'm meaning to format dates on my social web app much like Digg.com and other sites do. There, you see very friendly dates, such as:
just now 3 minutes ago one hour ago 2 weeks ago 6 monts ago ...you get the idea. Before I wrap my head around creating...
Started by Ferdy on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If you load a page and it says "posted 5 minutes ago" and look again 5 minutes later, it says "posted 10 minutes ago"
You can also do this in SQL:
http://stackoverflow.com/questions/50149/best-way-to-convert-datetime-to-n-hours-ago....
|
|
How to check whether the given date is earlier than a month ago? What is the fastest algorithm? I have to take into account that different months have different numbers of days.
Started by mykhaylo on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If (dt1.plusMonths(-1) > dt2) { //Date is earlier than a month ago }.
|
|
Hi,
Does anyone have a simple function to hand for converting a date to a simple string (using .Net)?
E.g. 14-Oct-09 would read "Today", 13-Oct-09 would read "Yesterday" and 7-Oct-09 would read "1 Week Ago" etc...
Cheers, Tim
Started by TimS on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
MINUTE) return ts.Seconds == 1 ? "one second ago" : ts.Seconds + " seconds ago"; if (seconds < 60 * MINUTE) return ts.Minutes + " minutes ago"; if (seconds < 120 * MINUTE) return "an hour ago"; if (seconds < 24 ....
|
|
I wrote a SQL function to convert a datetime value in SQL to a friendlier "n Hours Ago" or "n Days Ago" etc type of message. And I was wondering if there was a better way to do it.
(Yes I know "don't do it in SQL" but for design reasons I have to do it...
Started by Jared on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Now(), INTERVAL 60 minute) and now() THEN concat(minute(TIMEDIFF(now(), compare_date)), ' minutes ago(), INTERVAL 24 hour) and now() THEN concat(hour(TIMEDIFF(NOW(), compare_date)), ' hours ago') ELSE concat(datediff(now(), compare_date....
|