# Timestamp

> To try it out today, please contact us at <support@vgs.io>

## Working with Timestamp

Larky (unlike Python) does not have built-in `time()` method, as there are certain reasons for that. However, there is a solution that provides a possibility of getting the current timestamp with the help of FCO (First Class Operations) and using this value directly in Larky code.

### Larky code sample

There is an example of code below that reads the imestamp value from the `ctx` storage and writes the result into the message body.

The snippet below contains tags from the YAML in order to show how to:

* Place the piece of configuration properly in your YAML
* Combine FCO and Larky together in one route filter

```python
operations:
  - name: github.com/verygoodsecurity/common/utils/date-time/Now
    parameters:
      var: ctx.timestamp
  - name: github.com/verygoodsecurity/common/compute/larky/http/Process
    parameters:
      script: |-
        load("@stdlib//json","json")
        load("@stdlib//builtins", builtins="builtins")

        def process(input, ctx):
          body = {}
          body['timestamp'] = ctx['timestamp']
          input.body = builtins.bytes(json.dumps(body))
          return input
```

### Testing

Request to send:

```bash
curl {VAULT_URL}/post \
  -H 'Content-Type: application/json' \
  -d '{ }'
```

Response example:

```json
{
  "timestamp": "1647887942783"
}
```

### Useful links

* [YAML file export/import](https://docs.verygoodsecurity.com/vault/developer-tools/vault-management/yaml)
