I have a script with moment js library running in a landing page and the purpose of the library is to check whether today falls in Daylight Saver.

If it does then the function sends a true statement and false if it doesn't.

In this context I want to capture the output of the function in an AMPscript variable so I can use it below to drive logics based on true or false results.

Here is what the landing page consists of:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
<script type="text/javascript">
var CheckDLS = moment().isDST();

I have also tried doing HttpGet and HttpPost on the landing page which consists of the script.

Does anyone know how to achieve this? Also I am open to any other suggestions on getting the Daylight Savings status within cloudPages.

  • You can't mix server-side and client-side JavaScript. SSJS is evaluated before the page is loaded, client-side during (and after) page load. Commented Jun 2, 2020 at 14:18

2 Answers 2


You would need to use AJAX to post the Front End JS value to SSJS (either on page load, or on user activity).

Then you can use the Variable.SetValue to set it to a AMPscript variable.


If you just want to pass simple variable data back and forth, you will need to use the SSJS functions GetValue and SetValue.


<script runat="server" language="javascript"> set var = 'Info'; Variable.SetValue("@Var","var"); </script> %%=v(@Var)=%%
  • using SSJS won't allow me to use the JS libraries. If you look at my post above I have mentioned the use of moment JS library, and the issue is I need to capture that either with SSJS or AMPscript. Btw I have resolved the Daylight Saver issue so I am not looking for a solution. Commented Feb 19, 2018 at 22:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .