Questions tagged [relative-time-span]

15 questions
1577
votes
39 answers

Calculate relative time in C#

Given a specific DateTime value, how do I display relative time, like: 2 hours ago 3 days ago a month ago
Jeff Atwood
  • 60,897
  • 45
  • 146
  • 152
138
votes
32 answers

How to calculate "time ago" in Java?

In Ruby on Rails, there is a feature that allows you to take any Date and print out how "long ago" it was. For example: 8 minutes ago 8 hours ago 8 days ago 8 months ago 8 years ago Is there an easy way to do this in Java?
jts
  • 1,539
  • 2
  • 12
  • 10
95
votes
17 answers

PHP How to find the time elapsed since a date time?

How to find the time elapsed since a date time stamp like 2010-04-28 17:25:43, final out put text should be like xx Minutes Ago/xx Days Ago
Mithun Sreedharan
  • 45,549
  • 69
  • 171
  • 232
2
votes
2 answers

Moment js determine how many days, weeks has passed

I'm not really good at handling datetime. I used momentjs for a ionic app for manipulating time but I want to achieve something that I couldn't. I used a pipe for that and I want to display based on if how many days have been passed or if weeks and…
2
votes
1 answer

getRelativeDateTimeString with day of week?

Is there any option to get getRelativeDateTimeString in day of week. Means if the date is within 7 days show it as Mon, 7:14am instead of 4 days ago, 7:14 am DateUtils.getRelativeDateTimeString(context, datewithTime.getTime(),…
Bincy Baby
  • 2,409
  • 4
  • 27
  • 53
1
vote
2 answers

How to subtract dates from each other

I am using Groovy. I have parsed a textfile whose lines contain information, including dates. I now have just the dates, for example: 08:13:16,121 09:32:42,102 10:43:47,153 I want to compare the deltas between these values; how can I do this? …
blaughli
  • 537
  • 5
  • 11
  • 25
1
vote
3 answers

Python how to merge the time spans and make a bigger one

I have the following dataframe. padel start_time end_time duration 38 Padel 10 08:00:00 09:00:00 60 40 Padel 10 10:00:00 11:30:00 90 42 Padel 10 10:30:00 12:00:00 90 44 Padel 10 11:00:00 12:30:00 …
gulbaz khan
  • 145
  • 1
  • 7
1
vote
1 answer

How to configure @nuxtjs/moment to use relativeTime settings for en locale

I am trying to display relative time in moment using the moment(...).fromNow() I am using the @nuxtjs/moment module It currently displays relative time as "15 days ago" etc. I want to change that to "15 d" As per THIS answer is how it can be done…
PirateApp
  • 4,149
  • 2
  • 34
  • 51
1
vote
1 answer

how to custom getRelativeTimeSpanString

I want to use getRelativeTimeSpanString to show a date.but I couldn`t set Locale to this class for showing date base on my locale! how can I custom this class? is it possible to add locale as a parameter to this class? final CharSequence…
Zahra.HY
  • 1,538
  • 1
  • 12
  • 25
0
votes
2 answers

How to calculate relative time spans using Java (code converting problem)?

I decided to give myself a challenge on Java that implements this question's achievement. The things I have to do is get LocalDateTime, convert the same code from the linked question's answers, then receiving a string from the function. Here's what…
user14793609
0
votes
3 answers

How do I get input of multiple values using Java?

Using Vincent Robert's answer, I want to rebuild it in Java. I started off this way: // This is a draft of the program. import java.time.LocalDateTime; import java.util.Scanner; import java.lang.*; public class Test { public String…
user14773097
0
votes
3 answers

how to calculate relative time in ruby?

How to calculate relative_time for seconds,minutes, days, months and year in ruby? Given a DateTime object, implement relative time d = DateTime.now d.relative_time # few seconds ago Possible outputs # few seconds ago # few minutes ago - till 3…
nim
  • 1
  • 2
0
votes
1 answer

Show relative time based on timestamp

I'm using Kibana to show the statuses of multiple microservices based on the most up to date value for each. I would like to replace the April 8th 2019, 14:37:13.173 format with somethine like 2 minutes ago or 2 minutes 21seconds ago. I know I can…
0
votes
1 answer

i have a date and time, i want to conver into a relativeTime like twitter. i tried moment.js but it dost not work

I am looking for to convert this date and time to relative time like twitter have ex. 5 sec ago or 1 month ago. I have stored date and time in different column of database. i am executing this in JavaScript, i tried Momentjs but it does not work…
0
votes
1 answer

Show one day, one hour ago not working correctly?

i have done with this code + (NSString *)relativeDateStringForDate:(NSString *)date { NSString *temp; NSString* format = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; // Set up an NSDateFormatter for UTC time zone NSDateFormatter* formatterUtc =…
karthikeyan
  • 513
  • 2
  • 7
  • 24