> For the complete documentation index, see [llms.txt](https://ampersandtarski.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ampersandtarski.gitbook.io/documentation/the-language-ampersand/current-date.md).

# Current date

How do you get the moment your script has started to run?

The runtime system of Ampersand contains a function that produces the current date. Here is an example how to use it:

```
CONTEXT CurrentDate

   RELATION sessionToday[SESSION*Date] -- or whatever the DateTime concept is called
   REPRESENT Date TYPE DATE
   ROLE ExecEngine MAINTAINS "Initialize today's date"
   RULE "Initialize today's date": I[SESSION] |- sessionToday;sessionToday~
   VIOLATION (TXT "{EX} SetToday;sessionToday;SESSION;", SRC I, TXT ";Date")

INTERFACE Overview : "_SESSION" cRud
BOX [ date : sessionToday cRuD ]

ENDCONTEXT
```

If you run this program, this is what you'll see

![](https://3502282321-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9s__kkYiQvvyW5CKOk-887967055%2Fuploads%2F6QJgp1UGgVFOtKTebMkC%2Fimage.png?alt=media\&token=eb3e4f97-8224-4278-ad3c-6050e7bd8085)

### Explanation

The rule "Initialize today's date" tells us that there must be a date for every session. When your session starts, there is a session atom: `_SESSION`. The relation `sessionToday` does not relate that session atom to a date, so the rule is violated. As a consequence, the ExecEngine triggers the violation and calls the function `SetToday`. That PHP-function creates the desired link in the relation `sessionToday`. That is then displayed in the user screen.
