문제

I want to run a scheduled job every 10 minutes which will do the following: Check the table records and delete those who hasn't been updated for 10 minutes.

How is it possible to get the current server date in javascript in order to compare it?

도움이 되었습니까?

해결책

Use the JavaScript Date object. Just creating a new Date object without parameters will give you the server date and time. It will of course be in GMT as all the servers in Azure run on GMT. However, be aware of clock drift. Each of the servers could be slightly off from one another time wise, so it may not be exact if comparing times across servers.

var cutOfDate = new Date();

You could also load up one of the JavaScript data libraries like Moment or something like that as well if you need to do a lot of date formatting or evaluations.

Another option is to simply have a stored procedure that is called to perform your clean up for you. The stored procedure could then use the SQL GETDATE() to determine the current date and do the deletes based on that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top