Answer the question
In order to leave comments, you need to log in
Are there ready-made libs for JS, PHP, C#, Java, ObjC/Swift for manipulating the date and time, like writing "3 hours ago" nicely, etc.?
For example, you give seconds to the function (or 2 timestamps at once, and <<seconds>> between them it will find itself), and it returns a beautiful value like: "just now", "2 minutes", "year", etc.
various options are also possible, for example, "3 hours ago" is not always convenient, sometimes "2 hours 50 minutes" is better, etc.
Obviously, in different languages (not PL, but human ones), the code may differ slightly. but even under English it will work - you can transfer it to Russian
Or here: find the difference between two dates in the format of the string "hours:minutes" (return <<seconds>>), check if this time is a day off (if today is 23:00 on Friday , and the string is "0:00", then it will be, and if it's already 23:00 Sunday,
- write yourself. at the same time I will improve algorithmic skills, otherwise they are simply none. but improvement always takes more effort, but you have to do the work ...
- dig from different sites, what is not there - then write.
But maybe you should just take it ready?
PHP and JS are needed for
C# sites for applications under the classic Windows
Java for Android
ObjC / Swift - you understand
Answer the question
In order to leave comments, you need to log in
moment.js
At the
bottom of the page, select which languages you need.
There is a similar one for php moment.php
And the difference between two dates in seconds is calculated in one line in most languages.
In js something like this
In PHP
$diff = strtotime('2017-08-10 09:20') - strtotime('2017-08-10 09:16');
JS - https://momentjs.com/
PHP - https://github.com/fightbulc/moment.php or https://github.com/briannesbitt/Carbon
Do you want one library that contains all languages? This does not happen, the library is associated with a specific language, but some languages have ports. There are several hundred languages ( 1 , 2 ), do you want the author of such an uber library to make all the languages?
>But maybe you should just take it ready?
Of course, ready, if you already have it and if it is of decent quality.
Stalker_RED showed libraries for js and php. For c# there is https://github.com/Eonasdan/MomentSharp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question