Runtime verified Test scripts included

Syntax

Now([persistFormat])  →  date
0–1 arguments

Parameters

Name Type Required Description
persistFormat string | boolean | number No Selects the send job time instead of the current time when the content is rendered by a send

The argument accepts 1/0, true/false, or any of those four words quoted as a string. On a CloudPage it makes no difference to the value.

Example

%%[
  VAR @stamp
  SET @stamp = Now()
]%%
%%=v(@stamp)=%%

That renders the US short date followed by a 12-hour clock and an AM or PM suffix — month, day, four-digit year, then the hour without a leading zero.

Because the value is a real date rather than text, it goes straight into the other date functions:

%%[
  VAR @expires
  SET @expires = FormatDate(DateAdd(Now(), 7, "D"), "yyyy-MM-dd")
]%%
<p>Offer valid until %%=v(@expires)=%%.</p>

Return value

date — the system date and time.

There is no closed set of sentinel values to test for: the value is a point in time and a rejected call aborts the page rather than returning a marker.

Behaviour

The value is Central Standard Time, with no daylight-saving shift. Measured against a UTC reference in the same August render, the returned time ran six hours behind — the winter offset, not the five-hour summer one. It is also not the business unit’s own local time: SystemDateToLocalDate applied to the same value returned a time exactly 480 minutes ahead of it, so a page that needs the reader’s clock has to convert.

Every call within one render returns the same instant. A captured copy, a later separate call and the banner printed at the top of the same page all agreed — and not merely to the second: two separate calls read to six fractional-second digits produced identical values within a render, and different ones across renders. A page can therefore call it repeatedly without the timestamps drifting apart.

The value is a date, not a string. DateAdd advanced it by three hours, DateDiff measured that gap back as 3, and DatePart extracted the year and the hour from it directly, with no parsing step.

The argument is accepted in any spelling and changes nothing on a CloudPage

Call Result
Now(1) / Now(0) the same instant as a bare Now()
Now(true) / Now(false) the same instant
Now("1") / Now("true") the same instant
Now("spring") the same instant

The DateDiff in minutes between Now() and Now(1) in one render was 0. The argument selects the send job’s start or publish time, which only exists when a send renders the content — a CloudPage has no such context, so the switch has nothing to select and the current time comes back regardless. Nothing about the argument is validated either: a word that is not a flag at all was accepted as readily as 1. That is why the parameter is typed as three types rather than one.

Show test script
%%[
  VAR @b, @cap
  SET @b = RequestParameter("b")

  /* the default value, its date-ness, its timezone and its stability */
  IF @b == "safe" THEN
    OutputLine(Concat("--- safe start ---"))

    /* the rendered format: US short date, then a 12-hour clock */
    OutputLine(Concat("NOW0=[", Now(), "]"))

    /* a real date value - the other date functions consume it directly */
    OutputLine(Concat("ADD3H=[", DateAdd(Now(), 3, "H"), "]"))
    OutputLine(Concat("DIFF3H=[", DateDiff(Now(), DateAdd(Now(), 3, "H"), "H"), "]"))
    OutputLine(Concat("PARTY=[", DatePart(Now(), "Y"), "]"))
    OutputLine(Concat("PARTH=[", DatePart(Now(), "H"), "]"))

    /* the timezone, by comparison: LOCAL is the business unit's own time,
       and OFFSETMIN is how far ahead of the system clock it runs */
    OutputLine(Concat("LOCAL=[", SystemDateToLocalDate(Now()), "]"))
    OutputLine(Concat("OFFSETMIN=[", DateDiff(Now(), SystemDateToLocalDate(Now()), "MI"), "]"))

    /* frozen for the render: TICKA and TICKB are two separate calls read
       to six fractional-second digits, and they match */
    SET @cap = Now()
    OutputLine(Concat("TICKA=[", FormatDate(Now(), "ffffff"), "]"))
    OutputLine(Concat("TICKB=[", FormatDate(Now(), "ffffff"), "]"))
    OutputLine(Concat("CAP1=[", @cap, "]"))
    OutputLine(Concat("SECOND=[", Now(), "]"))
    OutputLine(Concat("DRIFTMS=[", DateDiff(@cap, Now(), "MI"), "]"))

    OutputLine(Concat("--- safe done ---"))
  ENDIF

  /* the argument as a number and as a boolean - D1 is 0 because none of
     them changes the value on a CloudPage */
  IF @b == "flags" THEN
    OutputLine(Concat("--- flags start ---"))
    OutputLine(Concat("N1=[", Now(1), "]"))
    OutputLine(Concat("N0=[", Now(0), "]"))
    OutputLine(Concat("BT=[", Now(true), "]"))
    OutputLine(Concat("BF=[", Now(false), "]"))
    OutputLine(Concat("D1=[", DateDiff(Now(), Now(1), "MI"), "]"))
    OutputLine(Concat("--- flags done ---"))
  ENDIF

  /* the same argument written as quoted strings */
  IF @b == "strflags" THEN
    OutputLine(Concat("--- strflags start ---"))
    OutputLine(Concat("S1=[", Now("1"), "]"))
    OutputLine(Concat("S0=[", Now("0"), "]"))
    OutputLine(Concat("STRUE=[", Now("true"), "]"))
    OutputLine(Concat("SFALSE=[", Now("false"), "]"))
    OutputLine(Concat("--- strflags done ---"))
  ENDIF

  /* a value that is not a flag at all is accepted rather than rejected */
  IF @b == "badarg" THEN
    OutputLine(Concat("--- badarg start ---"))
    OutputLine(Concat("BAD=[", Now("spring"), "]"))
    OutputLine(Concat("--- badarg done ---"))
  ENDIF

  /* this branch aborts the page: the start marker never renders */
  IF @b == "a2" THEN
    OutputLine(Concat("--- a2 start ---"))
    OutputLine(Concat("A2=[", Now(1, 1), "]"))
  ENDIF
]%%

Availability

Platform Available
Marketing Cloud Engagement Yes
Marketing Cloud Next Yes, from API 67.0

See also