For example, I create a block in which I write "a car like this and that" and when I save it in the code, make sure that the date of its creation is shown later! If today created something written "Today", if one day passed, then "yesterday", if 2 days passed then "2 days ago"! That is, how to do it so that they are substituted at a certain time after creation? How to write in contact after adding a movie there as well! Thanks in advance if someone tell me!

  • save the date in the database, then compare it with the current one and from this you dance, hardly anyone will give the ready code - Vitaly Pozdnyakov
  • As I understand it, the date is calculated using JS, the server only transmits two timestamps. The question is to clarify whether not only the date, but also the time, say, “2 hours ago” is needed. - Im ieee
  • Right now is not the topic, but for such dates ("today", "yesterday" etc) is ready to kill. No, not just to kill, but to kill with extreme cruelty. And on the topic - nothing is clear. Who concludes that at the entrance, from where, in what format comes ... - user6550
  • A site without a database? Maybe somehow I myself entered the point of reference, without determining the present tense! The main thing is not to countdown was, and the countdown "forward" - Alexei Poles
  • I just create the block myself in the code and I want it to start counting the time not in the opposite direction until a certain date (since there are enough ready-made solutions on the Internet) but forward and without a certain date just to count the hours of the minute days only ahead) - Alexey Poles

1 answer 1

Perhaps this Moment.js library will help you .

A javascript date library for parsing, validating, manipulating, and formatting dates.