Expand my Community achievements bar.

Current Date Via Profile Script

Avatar

Level 2

Hi, What I am trying to achieve is - to capture the current date via profile script but now when I changed the system date to another future date and then fetch the current date then still from the profile script it is showing the current date value.

Example: Suppose the current date is 4 June and I set the date from my system to future date i.e 10 June but the profile script is fetching 4 June date.

6 Replies

Avatar

Community Advisor

Hi @divyas46613305  I did this and it is working as expected :

var nd=new Date("10 June 2020");
var cd= new Date();

if(nd.getDate() > cd.getDate())
{
return true;
}


 
Updating Media

 

Thanks for your reply.

As you have passed one static value and then comparing with the new date.

I have just created simple profile script 

var ndate= new Date();

return ndate;

 

In this scenario, it is returning 4 June (i.e Today Date) which is correct as expected.

Now, I have changed the System date manually to 10 June then again run this profile script code and getting 4 June still but I believe it has to return 10 June (from the system date).

 

Avatar

Community Advisor

Hi @divyas46613305  profile scrips are evaluated on server side so nDate is giving you the value of edge server date . 

Hi @ambikaTewari_ATCI yes profile script is evaluated on the server-side basis.

However, one month ago when I tried to fetch the date with the same scenario and by changing the date manually to some future date at that time it is returning the same future date.

If I set the date of my system 5 April then it will return 5 April 

Avatar

Level 4

Hello Divya,

 

Since the Profile Scripts are in the Form of Server Side JavaScript it will return server Date only even if you change your system Date.

If you want to use your system Date in Profile Script then pass your System Date in mbox parmater and access it in Profile script.

 

Thanks,

Charles