Time posted

On this page with the posts, you have it showing the date of when it was posted, eg. 28m
Is there a walk through to show how to do this?
It would be a great addition to a site I am working on at the moment.

Haven’t used it yet, but I think with the ‘calculate difference’ in the date formatter you can do something similar

Yes, all you need to do is:

  1. On insert add the current date in the database
  2. On the page use the Date and Time component and compare the difference between the Date and Time (that’s the current date and time) component and the date stored in the database, using the data formatter.

is the any instructions on this Teodor as I can seem to work it out how to compare the dates in date formatter.

Hi,

Is there a way to calculate a time since a specific date? I found the opposite in the operations/Date&Time on App connect side.

Thanks for any feedback in advance!

Gabor

You can use the formatter option to calculate the time since your dynamic date.

  1. Add Date and Time component on the page, it returns current date/time.
  2. Add your dynamic date from your database on the page
  3. Click the formatter option in the data picker
  4. Add Days Until formatter
  5. Select the datetime returned by the Date And Time component
1 Like

thanks Teodor, I can get that working. However when its less than one day ago, how to I get it to show 41 mins ago? At the moment it shows 0 days.
One here it has the minutes, hours then it changes to days and after a month it changes to months.
This is what I want to achieve is this possible with wappler? If so how could I do this.

For showing less than 0 days, just use the formatter.
Regarding on what to show you can set a dmx-show condition.
I will describe in words, you can use the formatter achieve this,
For example if time is more than 24h then show dates.
If time is more than 720 (30d x 24) then show month. Here there is an issue with February which has less than 30days.

Hope this helps you get started

Trying to figure this out too … got this far:

{{data_view_announcements.data[0].a_date.daysUntil(today_date.datetime) == 0 ? (data_view_announcements.data[0].a_date.minutesUntil(today_date.datetime)) + “m ago” : data_view_announcements.data [0].a_date.daysUntil(today_date.datetime) + " days ago"}}

This will give eg: 2 Days ago or -30m ago. Just can’t figure out why it put “-” for minutes.

I could use dmxShow but thought to try it this way first…

Is it putting -30 minutes ago, because it really was negative 30 minutes ago? Seems it is just a calculation formula you have to change

yes but for days it doesn’t put “-” outputs a positive number…

AAH my mistake in the Datetime element i had set Intervals to Days (whatever that means) . i changed to minutes and it worked fine. now it says 500m ago :slight_smile: :slight_smile:

Solution :slight_smile:

Outputs m, hr and days …

{{(data_view_announcements.data[0].a_date.minutesUntil(today_date.datetime) > 1440) ? data_view_announcements.data [0].a_date.daysUntil(today_date.datetime) +“days ago” : ((data_view_announcements.data[0].a_date.minutesUntil(today_date.datetime) >= 60) ? data_view_announcements.data [0].a_date.hoursUntil(today_date.datetime)+“h ago” : data_view_announcements.data [0].a_date.minutesUntil(today_date.datetime)+ “minutes ago” ))}}

1 Like