Current Date Via Profile Script

Avatar

Avatar
Validate 1
Level 1
divyas46613305
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
divyas46613305
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
View profile
divyas46613305
Level 1

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

Avatar

Avatar
Give Back 5
Level 4
LordOfTheRings
Level 4

Likes

66 likes

Total Posts

128 posts

Correct reply

24 solutions
Top badges earned
Give Back 5
Validate 10
Validate 1
Contributor
Shape 1
View profile

Avatar
Give Back 5
Level 4
LordOfTheRings
Level 4

Likes

66 likes

Total Posts

128 posts

Correct reply

24 solutions
Top badges earned
Give Back 5
Validate 10
Validate 1
Contributor
Shape 1
View profile
LordOfTheRings
Level 4

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

 

Avatar

Avatar
Give Back 5
Level 4
LordOfTheRings
Level 4

Likes

66 likes

Total Posts

128 posts

Correct reply

24 solutions
Top badges earned
Give Back 5
Validate 10
Validate 1
Contributor
Shape 1
View profile

Avatar
Give Back 5
Level 4
LordOfTheRings
Level 4

Likes

66 likes

Total Posts

128 posts

Correct reply

24 solutions
Top badges earned
Give Back 5
Validate 10
Validate 1
Contributor
Shape 1
View profile
LordOfTheRings
Level 4

04-06-2020

LordOfTheRings_0-1591269280709.png

 

Avatar

Avatar
Validate 1
Level 1
divyas46613305
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
divyas46613305
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
View profile
divyas46613305
Level 1

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

 

Avatar

Avatar
Give Back 5
Level 4
LordOfTheRings
Level 4

Likes

66 likes

Total Posts

128 posts

Correct reply

24 solutions
Top badges earned
Give Back 5
Validate 10
Validate 1
Contributor
Shape 1
View profile

Avatar
Give Back 5
Level 4
LordOfTheRings
Level 4

Likes

66 likes

Total Posts

128 posts

Correct reply

24 solutions
Top badges earned
Give Back 5
Validate 10
Validate 1
Contributor
Shape 1
View profile
LordOfTheRings
Level 4

05-06-2020

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

Avatar

Avatar
Validate 1
Level 1
divyas46613305
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
divyas46613305
Level 1

Like

1 like

Total Posts

8 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back
Boost 1
View profile
divyas46613305
Level 1

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 

Avatar

Avatar
Establish
Level 3
Charles_Thirupathi
Level 3

Likes

17 likes

Total Posts

36 posts

Correct reply

8 solutions
Top badges earned
Establish
Validate 1
Shape 1
Give Back
Boost 5
View profile

Avatar
Establish
Level 3
Charles_Thirupathi
Level 3

Likes

17 likes

Total Posts

36 posts

Correct reply

8 solutions
Top badges earned
Establish
Validate 1
Shape 1
Give Back
Boost 5
View profile
Charles_Thirupathi
Level 3

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