|
Hi everyone,
i am trying to convert a timestamp of the format: 2009-09-12 20:57:19 and turn it into something like '3 minutes ago' with php.
I found a useful script to do this, but I think its looking for a different format to be used as the time variable...
Started by cosmicbdog on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
(((2008-1970) 365)+(8 30)+12)*24+20 would give you a ROUGH estimate of the hours since January... .
For example for the timestamp, 2009-09-12 20:57:19.
You'll have to take each individual piece of your timestamp, and convert it into Unix time .
Try strtotime().
|
|
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....
|
|
We've got AGO for sale---Lagos offshore waters Very good price. Can fulfill large orders! but you MUST agree to our procedure, no exceptions! Interested?Write: adceterang@gmail.com or call: 08098292953 NOW!
Started by MMagnet on
, 10 posts
by 1 people.
Answer Snippets (Read the full thread at nairaland):
COOKED AGO AND FORCADOS BRENT ALSO.
AGO ALSO AVAILABLE CALL FOR DETAILS AND PROCEDURE, NEW STOCK NOW AVAILABLE PLS CALL FOR OUR;<<STILL AVAILABLE>>>> GONE, NEW STOCK EXPECTED.
|
Ask your Facebook Friends
|
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 ,... .
|
|
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_....
|
|
In MySQL, how would I get a timestamp from, say 30 days ago?
Something like:
select now() - 30
The result should return a timestamp.
Started by Ben Noland on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
DATE_SUB will do part of it depending on what you want
mysql> SELECT DATE_SUB(NOW(), INTERVAL 30 day); 2009-06-07 21:55:09 mysql> SELECT TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 day)); 2009-06-07 21:55:09 mysql>... .
I think you are after DATE_SUB.
|
|
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 }.
|