E
E
Erl2017-10-30 12:39:59
Windows
Erl, 2017-10-30 12:39:59

How to display a block depending on the date?

there is suppose a structure that displays data of the form: |Icon*NEW*|Date*01.11.2017*|News text|
How can I implement the NEW output, and remove it 1 day after the news is published?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Ronald McDonald, 2019-08-03
@Zoominger

Well, connect by IP. If it's not grey, then everything will work.

A
Artem @Jump, 2019-08-03
curated by the

You need a white IP address on the device you are connecting to, or you need to forward ports from a device that has a white address.

A
Alexander Chernykh, 2019-08-03
@sashkets

I summarize. The remote router must have a white address. On this router, we configure port forwarding to the address of the desired server. Connects by dns name, if dns is configured. Or white address. default rdp port 3389

A
Alexey Burlakov, 2017-10-30
@NooBiToo

If you only have jQuery - you need to somehow save the time of the first publication. Either on the server (which is the easiest), or if you receive data via ajax - save the date of each new news in cookies.
And then, when you display news in a loop, check the date and compare it with the current one. Checking is best done in unixtime, for example:

...
var savedDate = cookies.get("newId");//получили сохраненную ранее дату отдельной новости
var curDate = new Date();//получили текущую дату
if(+savedDate + 60*60*24* 1000 < +curDate) {//60c * 60 мин * 24ч * 1000мс
//новость пора убирать
}
...

* +savedDate - added to the variable "+" converts the date to unixtime format.
* multiply by 1000ms, because in js unixtime is created with millisecond precision.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question