Questions tagged [relative-date]
48 questions
2
votes
1 answer
PHP Function to Calculate Relative Time (Human Readable / Facebook Style)
function RelativeTime($timestamp) {
$difference = time() - $timestamp;
$periods = array(
"sec", "min", "hour", "day", "week", "month", "years", "decade"
);
$lengths = array("60", "60", "24", "7", "4.35", "12", "10");
…

0pt1m1z3
- 841
- 3
- 12
- 23
2
votes
2 answers
Using and comparing relative time in Rails
I need to know how to do relative time in rails but not as a sentence, more like something i could do this with (when i input format like this 2008-08-05 23:48:04 -0400)
if time_ago < 1 hour, 3 weeks, 1 day, etc.
execute me
end

Kevin
- 1,574
- 4
- 19
- 45
2
votes
0 answers
how to get relative date from absolute date ? in shell
Consider dates of the format:
2022-06-18T11:03:40+0800
1655107420
...
How could you get dates with relative information (i.e the time delta N minutes ago):
Saturday, June 18, 2022 at 11:32:30 (3 minutes ago)
Saturday, June 18, 2022 at 11:19:03 (17…

8c6b5df0d16ade6c
- 1,910
- 15
- 15
2
votes
1 answer
How to create Dynamic date parameter in Quicksight?
I am new to Amazon-Quicksight. I tried different approaches but unable to find a solution, so posting it here.
I have a excel file having Actual sales data (including historic data) that gets updated daily. I have to create a day over day comparison…

user14104670
- 51
- 4
2
votes
0 answers
Is Range selection possible in WPF Date Picker?
My requirement is to have some relative date support in my date picker and I want to select start and end date from wpf date picker. But picker showing single calendar and i couldn't achieve two date selection.i have gone through some sites but…

IndraJeyan
- 119
- 7
2
votes
2 answers
Yii2 formatter relativeTime() is not working on shared host
It's working properly on local server, but when I upload it to the shared host, instead of displaying relative date it shows raw string.
code:
Yii::$app->formatter->asRelativeTime($timestamp, 'now');
local host:
in 6 days
shared host:
in {delta,…

mt.andi
- 143
- 1
- 12
2
votes
5 answers
Short formatted relative time in iOS?
I'm using the NSDate-TimeAgo library to format relative time in my iOS application. It displays the relative time of each post in its cell header, as so:
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd…

swiftcode
- 3,039
- 9
- 39
- 64
2
votes
3 answers
How to get timestamp of MySQL table in relative time on website
I want to know, step by step, the way to transform a timestamp in my mysql table to a relative time (4 seconds ago, 5 months ago...) on my website.
For information, my timestamp column is named creation, and my table is named users.
The code I…
user2475897
1
vote
1 answer
Turning a variable containing the number of months to X Years, X Months format?
This is a bit like the popular relative time (ago) except I'm not dealing with a timestamp but the number of months.
I'm not sure on how to go by this though?
Heres some examples to improve your understanding of my question:
If input…

user962026
- 207
- 1
- 5
- 12
1
vote
4 answers
Android: Convert string to a time
I am trying to convert a string that contains a time stamp to a time that is consistent with androids RelativeDateTimeString, so I can format it as a relative time. The time stamps that I get are in this format:
2011-08-17 04:57:38
I would like to…

Nick
- 9,285
- 33
- 104
- 147
1
vote
1 answer
Convert relative time to datetime in Javascript
How can I convert a relative date/time string to a real date/time in Javascript (can use libraries)
For example, the user will input into an edit field any of the following examples (among others):
THIS IS THE INPUT:
2 weeks ago
Last 3 weeks
24…

Tr-evor H-awes
- 21
- 9
1
vote
1 answer
Assigning a date relative to another record's date
I'm building a Rails 4.2+ application that has Workflows and Tasks. A task.due_date can either be a specified date (such as "01/01/2017") or it can be relative to a date on the parent workflow record.
class Workflow < ApplicationRecord
#…

Dan L
- 4,319
- 5
- 41
- 74
1
vote
1 answer
How to create a relative linux crontab in bash: NOW (date) + 24 hrs
I need a way to create an entry on the crontab that executes a script only once in 24h.
Steps:
Run a bash script to configure a crontab to run a script in 24h (with command date?). This will run only ONCE 24 hs after .
24h later the script…

Matias Burni
- 509
- 6
- 11
1
vote
1 answer
Relative date and a cleaner "yesterday" & "the day before yesterday"
I modified a script to get a relative date from a timestamp (x times ago) and I would like to tweak it to add another level of precision like "yesterday" or "the day before yesterday".
Tried this and it works but it's not very clean, do you have an…

flks
- 610
- 10
- 28
1
vote
2 answers
Relative time function in js for format YYYY-MM-DDTHH:MM:SS+0000
I was wondering if anyone knew how I could parse this type of date format: 2010-07-26T18:02:46+0000
into the relative time such as "30 seconds ago"
I already have a function which does it for a similar but different time format:
function…

Stefan P
- 1,013
- 2
- 18
- 34