diffForHumans ( ts )
Convert timestamp difference to human readable text
Be the first to rate this function Log in to vote
Ãngel MartÃnez Fernández - Show more from this author
Lesterius Barcelona https://www.lesterius.es/ |
//Result:
12 minute(s) ago
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
Just as Carbon docs describes it:
It is easier for humans to read "1 month ago" compared to "30 days ago". This is a common function seen in most date libraries so I thought I would add it here as well.
Comments
TA May 20, 2020 |
||
Thanks for the upload, When It is 8 days ago, it still shows 1 week ago. Same thing from 8 to 13 days, All show 1 week ago. I am doing something wrong? I even tried it against a time difference for Date of Birth, the difference can be up to a year. |
||
Ãngel MartÃnez Fernández, Lesterius Barcelona May 20, 2020 |
||
Hello TA, You are doing it right, var “d†The difference in days, and in your case “8†is being divided by “7†inside of var “w†being the result “1,1428571429â€, then in the Case() as var “w†is greater than 1, it show the “1 week agoâ€. If you want the function to only show the difference up to days. The Case() should be like this: Case ( d ≥ 1 ; d & " day(s) "; h ≥ 1 ; h & " hour(s) "; m ≥ 1 ; m & " minute(s) "; s & " second(s) " ) |
||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.