Highlighted

Current Date Via Profile Script

Avatar

Avatar

divyas46613305

Avatar

divyas46613305

divyas46613305

03-06-2020

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.

Replies

Highlighted

Avatar

Avatar

LordOfTheRings

Avatar

LordOfTheRings

LordOfTheRings

04-06-2020

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

 

Highlighted

Avatar

Avatar

LordOfTheRings

Avatar

LordOfTheRings

LordOfTheRings

04-06-2020

LordOfTheRings_0-1591269280709.png

 

Highlighted

Avatar

Avatar

divyas46613305

Avatar

divyas46613305

divyas46613305

04-06-2020

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

 

Highlighted

Avatar

Avatar

LordOfTheRings

Avatar

LordOfTheRings

LordOfTheRings

05-06-2020

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

Highlighted

Avatar

Avatar

divyas46613305

Avatar

divyas46613305

divyas46613305

06-06-2020

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 

Highlighted

Avatar

Avatar

Charles_Thirupa

Avatar

Charles_Thirupa

Charles_Thirupa

06-06-2020

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