Free-Conversant Support / Cookie Conditional: cookie.[name].toDate
 Home   About Conversant   Free Sites   Hosting   Support   XML-RPC 

Search



Documentation >> Conditionals >> Cookies >> cookie.[name].toDate

Cookie Conditional Macro: cookie.[name].toDate

Operators:

  • == (equal to)
  • != (not equal to)
  • greaterThan
  • greaterThanOrEqualTo
  • lessThan
  • lessThanOrEqualTo

Usage Notes

  • You *should* make sure that the cookie exists before testing its date value, using cookie.[name].exists
  • Coerces the value of a cookie to a date-time value for comparison. This will typically be used along with the date.now conditional macro to test a cookies value in relation to the current time, but could also be used in combination with a date-type custom field.
  • Substitute the actual name of a cookie for the [name] (no brackets) portion of the macro.

Example

This example will show the first line if the cookie exists and its date value is "before" (less than) today. Otherwise it shows the second line.

<!--#if condition="cookie.sellByDate.exists && ( cookie.sellByDate.toDate < date.now )"-->

1. Like spoiled milk, you have passed your expiration date. Sorry.

<!--#else-->

2. Congratulations, you're still fresh!

<!--#endif-->

See the above code in action, here:

2. Congratulations, you're still fresh!
View in DG