There is time: anyone written a liquid solution of timespan for seconds, minutes and hours to share

Compliments of the season to you all. I am trying to create a timespan that ends in 'ago' at the end to show when an element of the webapp is out. For example:

If it's seconds, "there are 2 seconds'

If it's minute, "there are 1 min"

If there is time, "1 hour ago"

If day is "there are 1 day"

If there are months ' 2 months ago"

If this is year "1 year ago"

One with a liquid to share loans is appreciated. Thank you.

It is done in a hurry, a cleaner version is possible with a pretty picture initially but it is here:

{% assign myDate = "2016-01 - 01 T 00: 00:01Z '-%}

{% assign time = myDate: convert: 'day'-%} {% Comment %} This is just an example, to change to what you need to {% endcomment %}

{% assign lengths = '86400,3600,60,1-' %}

{% assign lengthsArr = lengths | divided: "," %}

{% attribute the difference = globals.site.dateNow | minus: time-%}

{% assign timeSpan = difference | date: ' JJ ': 'hh': 'mm':'ss '-%}

{"% assign timeSpanArr As timeSpan | divided: ' ': '-%}

{% assign total: 0 - percent}

{% assign count = - 1-%}

{% for article on timeSpanArr-%}

{% set count = count | more: 1 %-}}

{% assign len = lengthsArr [count]: convert: «number»-%}

{% assign seconds = item: convert: 'number': times: len-%}

{% assign total total = | most: seconds-%}

{% endfor}

{% If the total}< 60="">

{assign [interval = "second, 1" | divided: "," %]}

{% elsif total< 3600="">

{assign [interval = "minute, 60 ': divided:","%]}

{% elsif total< 86400="">

{assign [interval = 'hour', 3600 | divided: "," %]}

{% elsif total< 2628000="">

{assign [interval = "day 86400" | divided: "," %]}

{% elsif total< 31556926="">

{assign [interval = "month, 2628000 ': divided:","%]}

{%-%}

{assign [interval = 'year 31556926' | divided: "," %]}

{endif %}

{% yield duration = range [0]-%}

{% affect terms = interval [0] | append: "s"-%} {% Comment %} As append doesn't work in pluralize {% endcomment %}

{% assign termSeconds = interval [1]: convert: «number»-%}

{% assign total = total %}

{% assign termseconds = termseconds | number: 'F1'-%}

{% assign timeAgo total = | divided_by: termSeconds-%}

{{timeAgo | round}} {{timeAgo | round | pluralize: terms, term}} ago

Hope this can help, I would like to know if there are problems with it. Thank you.

EDIT:-weeks and rounded the timeago var.

Tags: Business Catalyst

Similar Questions

  • How can I 'include' a file different php depending on time? Work on a 'Happening Now' page for an event and the need to plan a different content to load as the day continues. Thank you!

    Work on a 'Happening Now' page for an event and the need to plan a different content to load as the day continues. Thank you!

    The event has class sessions all day (3 days). I would like the page happening now to show what classes are going on right now and what is coming up next. I was hoping just to separate configuration files and load them when necessary, but open to all suggestions.

    PHP has a powerful set of date and time functions.

    To do this is to create a DateTime object and then use conditional logic to include the files you want. A better way would be to keep the details in a database and use the time to retrieve and display the details you want.

    A DateTime object using:

    $now = new DateTime();

    $hour = $now-> format ('G'); This gives you time to the 24 hour clock.

    If ($hour == 13) {}

    It is between 13:00 and 14:00

    } else if ($hour == 14) {}

    It is between 14:00 and 15:00

    } ....

  • Error Code C00D0FAB. Has anyone ever produces a solution that works for this error code?

    I tried all of the suggestions by the contributors of this forum (and a big thank you to them all in an attempt to address a problem that bothers the _ out of me), I rebooted Windows Vista 3 times, imported from different codec and packets, tried to re-download WMP and told me I had the latest version (WMP 11) run different programs of Malware in Mode safe run sfc/scannow five times and I'm still not close to correct the problem with my WMP. My computer is a Compaq Presario running the version of Vista Ultimate 32 bit.
    A response from anyone who has actually found a working solution would be greatly appreciated.

    Well after a long evening of playing with the same problem and looking for any help.  I upgraded my Nvidia Nforce Serial ATA controller and my media player works now.  I also improved other drivers beforehand if it can't just be this one.  It's under the IDE in the hardware section of the control panel.  Good luck to all others so unhappy as to met this seemingly intractable problem.

  • I'm so frustrated that I keep going round in circles with trying to talk to someone before my trail ended but no one is there any time I have opened a session. My journey has ended and I was charged for the year where I signed that

    Can someone help me with this problem!

    Hello

    I see that you have contacted our support team and they are trying to handle your request.

    Kind regards

    Bev

  • Lately, when I convert a Word document to pdf format, the pdf document is not the same, but it leaves out the parts of my Word document.  Do anyone know of a solution or fix for this problem?

    When I use Acrobat 9 to convert a Word file to pdf, the converted document does not match the original, but leaves rather parts of the original Word document.  Someone knows what to do?

    I found the problem and solved by changing the conversion of PDF from Adobe

    settings uncheck "enable accessibility and reflow with tagged Adobe."

    PDF. "Thank you.  John

    The game, 00:23, 2 July 2015, Anubha Goel [email protected]>

  • compare the minutes and hours of time

    Hello

    How to compare 11:30 to 12:00 as the two thing is of type string... I use the string nember converter but will return only 11.

    To do this, the easiest method is to format the string into a timestamp.  Then, you can simply subtract the stamps to indicate the number of seconds between your two stamps.

  • acquisition of wireless signals and record the signal as text at the same time for 5 minutes

    Hello

    I'm wireless ECG signal and the display in waveform graph. And at the same time, I need to save it as text for 5 minutes. The problem I faced is for record of the signal, I use scripture to the extent file that saves the file as text... but everything by saving the trace speed decreases.

    I'm very new to labview so please can someone me if Miss me something in it... Please help...

    Why people always post photos of their screws rather than the screws themselves or at least excerpts?  We can't tell from the picture what Version of LabVIEW, you use (so if we post code, you will not be able to open it), and we can not 'play' with your code and try without, ourselves, by hand, trying to recreate your diagram (sometimes very small).  Please, help us help you!

    This is in any case helps to familiarize yourself with the design of producer/consumer model.

    1. Open LabVIEW.
    2. Click on 'File', choose 'new '.... "(no new VI), then (in models) producer/consumer Design Pattern (data).
    3. Study the model and adapt it to your problem.

    The producer would be anything that generates data.  Once you have the data, you put on the queue and send to the consumer for the entire treatment.  The idea is that the producer has an inherent calendar that he must answer, otherwise you lose data points.  The consumer, on the other hand, just need to follow 'more or less' (in fact, the queue may / will develop, if the amount of data is not megabytes, so the consumer can really be quite slow, if you usually want to consumers, on average, to be at least as fast as the producer).

    Bob Schor

  • Hello. Yesterday morning, I installed Adobe Acrobat Pro XI, and due to the time required to download, I left my office for the day, back in the morning.  When I went to open documents filed electronically to the Federal Court in cases that I could

    March 31, 2016

    Hello.

    Yesterday morning, I installed Adobe Acrobat Pro XI, and because of the time needed to install, I left my office for the day and my computer left overnight. When I arrived at my office this morning, I checked my email and found Court electronic filing of notifications of PDF documents filed in two federal cases, I'm working on that. I went to open the documents in both cases, but the documents would not open, and I have lost these documents.  I could look at my computer screen and saw a message from reference in order for me to open documents, I had to accept the license agreement provided by Adobe.

    I'm not an individual computer, and I seriously need your help.  Could you please guide me for the license agreement I need to sign in order to retrieve and open PDFs that are filed in the federal courts, I practice before? I have some papers I have to drop off this morning in Federal Court, which must be filed in PDF, so time is critically important.

    Thank you for your help, cooperation and professionalism.  I sincerely appreciate your assistance.

    Best regards

    Dean Browning Webb, Esq.

    TV: [503] 629-2176

    Cel #: [253] 686-5111

    First of all, I'm sorry you had trouble. But you posted in the wrong place. This is the Adobe Connect forum, for users of Acrobat Connect Pro.

    How have you lost documents? If documents have been emailed to you, you should always be able to recover again from your email. Try to launch Adobe Acrobat FIRST, then using file > open to retrieve the documents where you stored the on your computer.

    Hereis a list of product licenses, but I do not think that this will help you. Try what I suggested and let me know what happened please. Good luck!

  • Clock on windows 8 is wrong time, I tried to set the time of the internet but its still not working, think theres a bug in the clock time, anyone have the same problem for windows 8 and know how to fix?

    Clock on windows 8 is wrong time, I tried to set the time of the internet but its still not working, think theres a bug in the clock time, anyone have the same problem for windows 8 and know how to fix?

    It sets obtained :-) Sorry for the delay

    Thank you very much! has worked perfectly!

  • KB2628259 doesn't install, cannot create the directory or file. Anyone know of a solution?

    KB2628259 doesn't install, cannot create the directory or file. Anyone know of a solution?

    Hi dakota25,

    ·         Did you do changes on the computer before the show?

    ·         You are able to install other updates successfully?

    ·         You get the error message?

    Follow these methods.

    Method 1: Temporarily disable the security software.

    Note: Antivirus software can help protect your computer against viruses and other security threats. In most cases, you should not disable your antivirus software. If you do not disable temporarily to install other software, you must reactivate as soon as you are finished. If you are connected to the Internet or a network during the time that your antivirus software is disabled, your computer is vulnerable to attacks.

    Method 2: Put the computer in a clean boot state to see if there is a software conflict as the clean boot helps eliminate software conflicts.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Note: After completing the steps in the clean boot troubleshooting, follow the section How to configure Windows to use a Normal startup state of the link to return the computer to a Normal startupmode.

    After the clean boot used to resolve the problem, you can follow these steps to configure Windows XP to start normally.

    (a) click Start, run.

    (b) type msconfigand click OK.

    (c) the System Configuration Utility dialog box appears.

    (d) click the general tab, click Normal startup - load all services and device drivers and then click OK.

    (e) when you are prompted, click on restart to restart the computer.

    Method 3: You can also manually install updates (KB number) by downloading from the Microsoft Download Center.

    http://www.Microsoft.com/downloads/en/default.aspx

    Method 4: Follow the steps in the article.

    How to reset the Windows Update components?

    http://support.Microsoft.com/kb/971058

    You cannot install some programs or updates

    http://support.Microsoft.com/kb/822798

  • When we try to write in a pdf file. document, it changes the Danish letters Æ Ø Å to different signs. To do this, this om pc and Mac. Anyone know of a solution? Thank you

    When we try to write in a pdf file. document, it changes the Danish letters Æ Ø Å to different signs. To do this, this om pc and Mac. Anyone know of a solution? Thank you

    Hi, I found the problem, it seems that the pdf file uses a helvetica font, and when we write in a part of the PDF with the Danish letters A, Æ, O, it changes signs. I changed the Roman fonts in adobe acrobat pro, and then there's no problem. But he seem´s that the standard in pdf files is helvetica, and there is not time to change the files, because we get only the files on the day of the exams at school. It happens in all versions of adobe 11 and DC, it is also a problem on Windows 7, 8.1 and windows 10 more Macbook.

    Kind regards

    Med Hotel hilsen

    Price Patrick Simon

    TI-Vejleder

    Langeskov Skole

    Ronningevej 38

    Langeskov 5550

    Denmark

    FRA: meenakshin83966505 [email protected]<>[email protected]>

    SVAR til: "[email protected]<>[email protected]> ' [email protected]<>[email protected]>" "

    Dato: måndag den 18. January 2016 kl. 14.39

    Til: Simon Price [email protected]<>[email protected]>

    Emne: You have been mentioned by meenakshin83966505 in Re: when we try to write in a pdf file. document, it changes the Danish letters Æ Ø Å to different signs. To do this, this om pc and Mac. Anyone know of a solution? Thanks to the Adobe community

    You talked

    by meenakshin83966505https://forums.adobe.com/people/meenakshin83966505?et=notification.mention> in Re: when we try to write in a pdf file. document, it changes the Danish letters Æ Ø Å to different signs. To do this, this om pc and Mac. Anyone know of a solution? Thanks to Adobe Community - see the reference from meenakshin83966505 to youhttps://forums.adobe.com/message/8402116?et=notification.mention#8402116>

  • Has anyone found or written a "Win 7 USB driver" for use with the Olympus C-3000Z digital camera?

    Has anyone found or written a "Win 7 USB driver" for use with the Olympus C-3000Z digital camera?

    On Fri, 28 September 2012 18:02:40 + 0000, bertcoy wrote:

    Has anyone found or written a "Win 7 USB driver" for use with the Olympus C-3000Z digital camera?

    Looking at the website of Olympus, it would appear that we do not
    There are.

    But you do not need a driver because you do not need to connect your
    camera to the computer. Just put the memory card in a card reader and
    access like this instead. I prefer to do it with my camera,
    because it is easier, faster and uses no battery in the camera.

    Ken Blake, Microsoft MVP

  • Publish the services in Lightroom: internal error? : 0:attempt to index field 'export setings' (value zero). On 10 64-bit windows. I uninstalled and reinstalled Lightroom (x 3), uninstalled and reinstalled the plugins etc, etc. Anyone with a real solution

    Hello

    I think I found the problem to which there is no solution. Lucky white Heather. This happens just as I'm building a site to which I'm now uploading - Smugmug.

    Publish the services in Lightroom: internal error? : 0:attempt to index field 'export setings' (value zero). On the 64-bit windows 10 platform: desktop. I uninstalled and reinstalled Lightroom (x 3), uninstalled and reinstalled the plugins etc, etc. Anyone with a real solution?

    Help

    Andrew

    Hi André,.

    See this similar thread: 'Services to publish' question in Lightroom

    Kind regards

    Claes

  • I'm having issues get notifications on my iPhone and my Apple Watch. Anyone know of a solution for this?

    I'm having issues get notifications on my iPhone and my Apple Watch. Anyone know of a solution for this?

    Difficulty what for? What "issues" are you having?

  • Parachute does not not between iOS and Mac devices... Does anyone have a good solution for it nor a lot of garbage to support

    Parachute does not not between iOS and Mac devices... Does anyone have a good solution for it nor a lot of garbage to support

    You want the solution? Why not tell us what Mac and Apple, mobile devices you have the OS and version?

    Also what troubleshooting steps you took?

    We do not have a crystal ball, and we're not sitting next to you.

Maybe you are looking for