Forum Documentation Showcase Pricing Learn more

New Plugin: Relative Time with Moment.js

#30

Yes it fixed the problem. People have to CLOSE their browser to get it fixed. I will look later if it bring other issue. Thanks.

1 Like

#31

I’m loving this plugin @louisadekoya, thank you for offering it for free.

This may be outside of the scope of this plugin, but I have another use case: the option to add a second date to use as relative time instead of current date time.

Let’s say you have a car. You have a PURCHASED date, and a SOLD date. By allowing a dynamic second date in the plugin, you could calculate something like " you owned this car for 2 years".

Is this a possibility?

0 Likes

#32

Hi @petter, thanks. The plugin doesn’t currently support this feature. It was my original intention to include it right from the start but I couldn’t quite make it work. I’ll take another look during the week and let you know.

1 Like

#33

Awesome @louisadekoya, thanks!

0 Likes

#34

Just started getting a error for every instance of Relativetime in my app. Just checked the demo site and the same error is occurring.

WARNING: Error parsing plugin code for update (Relative Time). Please check
function(a,b,e){var c=b.date_from;b=b.interval;var d=a.data.update_me;a.data.get_relative_time©;null!==b&&(null!=a.data.timer&&(clearInterval(a.data.timer),a.data.timer=null),a.data.timer=setInterval(function(){d©},b))};

0 Likes

#35

This seems to be happening everywhere. I’m currently getting “Error parsing plugin code” errors thrown with Expressions plug-in. There seems to be an overall Bubble bug with plugins at the moment… It’s pretty nasty. I assume the issue is being worked on (another user submitted bug report based on observations over in the Air Date/Time Picker thread…

0 Likes

#36

Thanks for pointing out the error. Looks to have been resolved now (by the Bubble team).

0 Likes

#37

Just confirming that I ran into this bug as well but it seems to be resolved.

It first manifested while I was using version 2.0.0 of this plugin. Upgraded to the new version, 2.1.0 and the issue persisted. But now things are working properly, so also of the belief it’s a Bubble bug. :slight_smile:

1 Like

#38

Hi All,

I have updated the plugin to add:

  1. The ability to hide the suffix. So you can have the current value as “2 days” instead of “2 days ago”. Also works for the prefix, so “2 days” instead of “in 2 days”.

  2. The ability to express your date relative to a defined baseline date instead of current date/time. See @petter’s post above for an example use case. Thanks for the suggestion, Petter.

I have updated the instructions and demo page. I hope you find the update useful.

Louis

3 Likes

#39

Making a great plugin even better. Really appreciate those changes! :smiley:

1 Like

#40

Thanks a lot, really great plugin!

I’m using the Language feature in Bubble, so I’m using Find and Replace to change the words in the plugin into the local language. For those who want the same, here are the strings used:

Range Key Sample Output
0 to 44 seconds s a few seconds ago
44 to 44 seconds ss 44 seconds ago
45 to 89 seconds m a minute ago
90 seconds to 44 minutes mm 2 minutes ago … 44 minutes ago
45 to 89 minutes h an hour ago
90 minutes to 21 hours hh 2 hours ago … 21 hours ago
22 to 35 hours d a day ago
36 hours to 25 days dd 2 days ago … 25 days ago
26 to 45 days M a month ago
45 to 319 days MM 2 months ago … 10 months ago
320 to 547 days (1.5 years) y a year ago
548 days+ yy 2 years ago … 20 years ago
3 Likes

#41

Hi @louisadekoya,

We would like have a relative time solution for a return data from API workflow. Do you know how we can hack this maybe using your plugin or something else?

0 Likes

#42

Hi @timothymugendi,

What exactly would you like to do? Please expand on “solution for a return data from API workflow”

I haven’t tried it but if your API is returning a valid date, you should be able to use it as the source date for the plugin.

0 Likes

#43

I actually want to send data to an external android app from Bubble db via API workflow. The way we send this data is to include a Return data from API action at the end of an API workflow as below:

image

What I wish to be able to do using your plugin is to convert this date to relative time text via such a workflow before returning it to my app. The means I will return a text instead of a date value.

So in this case, I would replace below workflow with results of Moment.js plugin

image

Let me know if you need more information.

0 Likes

#44

Have you tried it yet? I think you should and let me know how you get on. The plugin element takes a date as input and spits out some text, so in theory, if you pass it your result of step 1’s modified date you can set your return text to the plugin element’s value.

0 Likes

#45

@louisadekoya

Hi, thank you so much for this plugin. It seems incredibly useful, but for some reason, I cannot get anything to show. Using the debugger, it seems like all the data is passed correctly, but nothing appears :frowning:

0 Likes

#46

You’re part way there. In this case, you placed the relative time element in the repeating group. So, each individual cell would have its own relative value.

However, to expose the generated value (ex. an hour ago), you need to pull it into a text element that references RelativeTime B’s value.

2 Likes

#47

Ahhh how did I not realize that. Thank you :slight_smile:

2 Likes

#48

Hey! Thanks for the awesome plugin. Is there a way to use Moments.js with different languages?

0 Likes

#49

Thanks - I’m pleased that you find the plugin useful. The moment.js library does support ‘locales’, but this is not included in the plugin. I gather it significantly increases the size of the library that is loaded. If this is very important to your app, I can create a private ‘with-locales’ version of the plugin, which I could grant your app access to, but I can’t guarantee that I will maintain it going forward as I don’t want to commit to maintaining two versions - unless lots of people want the locales feature.

You can see it working here - note that the locale dropdown does not take a dynamic value. I’m afraid it would take more time than I have right now to make it so.

0 Likes