Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Current Date Via Profile Script

divyas46613305
Level 2
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
LordOfTheRings
Level 7
Level 7

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

 

divyas46613305
Level 2
Level 2

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).

 

LordOfTheRings
Level 7
Level 7

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

divyas46613305
Level 2
Level 2

Hi @LordOfTheRings 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 

Charles_Thirupathi
Level 3
Level 3

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