2019-11-08 03:19:27 +04:00
---
id: timestamps-addresses
title: Timestamps, Addresses
---
## Timestamps
Timestamps in LIGO, or in Michelson in general are available in smart contracts, while bakers baking the block (including the transaction in a block) are responsible for providing the given current timestamp for the contract.
### Current time
You can obtain the current time using the built-in syntax specific expression, please be aware that it's up to the baker to set the current timestamp value.
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
2019-12-26 17:21:17 +04:00
```pascaligo group=a
2019-11-08 03:19:27 +04:00
const today: timestamp = now;
```
2020-01-18 10:56:54 +04:00
<!-- CameLIGO -->
```cameligo group=a
let today: timestamp = Current.time
```
<!-- ReasonLIGO -->
```reasonligo group=a
let today: timestamp = Current.time;
```
2019-11-08 03:19:27 +04:00
<!-- END_DOCUSAURUS_CODE_TABS -->
2020-01-04 00:49:42 +04:00
> When running code with ligo CLI, the option `--predecessor-timestamp` allows you to control what `now` returns.
2020-01-04 00:38:40 +04:00
2019-11-08 03:19:27 +04:00
### Timestamp arithmetic
In LIGO, timestamps can be added with `int` (s), this enables you to set e.g. time constraints for your smart contracts like this:
#### In 24 hours
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
2019-12-26 17:21:17 +04:00
```pascaligo group=b
2019-11-08 03:19:27 +04:00
const today: timestamp = now;
const one_day: int = 86400;
const in_24_hrs: timestamp = today + one_day;
2020-01-04 00:38:40 +04:00
const some_date: timestamp = ("2000-01-01T10:10:10Z" : timestamp);
const one_day_later: timestamp = some_date + one_day;
2019-11-08 03:19:27 +04:00
```
2020-01-18 10:56:54 +04:00
<!-- CameLIGO -->
```cameligo group=b
let today: timestamp = Current.time
let one_day: int = 86400
let in_24_hrs: timestamp = today + one_day
let some_date: timestamp = ("2000-01-01t10:10:10Z" : timestamp)
let one_day_later: timestamp = some_date + one_day
```
<!-- ReasonLIGO -->
```reasonligo group=b
let today: timestamp = Current.time;
let one_day: int = 86400;
let in_24_hrs: timestamp = today + one_day;
let some_date: timestamp = ("2000-01-01t10:10:10Z" : timestamp);
let one_day_later: timestamp = some_date + one_day;
```
2019-11-08 03:19:27 +04:00
<!-- END_DOCUSAURUS_CODE_TABS -->
#### 24 hours ago
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
2019-12-26 17:21:17 +04:00
```pascaligo group=c
2019-11-08 03:19:27 +04:00
const today: timestamp = now;
const one_day: int = 86400;
2019-12-26 17:21:17 +04:00
const in_24_hrs: timestamp = today - one_day;
2019-11-08 03:19:27 +04:00
```
2020-01-18 10:56:54 +04:00
<!-- CameLIGO -->
```cameligo group=c
let today: timestamp = Current.time
let one_day: int = 86400
let in_24_hrs: timestamp = today - one_day
```
<!-- ReasonLIGO -->
```reasonligo group=c
let today: timestamp = Current.time;
let one_day: int = 86400;
let in_24_hrs: timestamp = today - one_day;
```
2019-11-08 03:19:27 +04:00
<!-- END_DOCUSAURUS_CODE_TABS -->
### Comparing timestamps
You can also compare timestamps using the same comparison operators as for numbers:
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
2019-12-26 17:21:17 +04:00
```pascaligo group=c
2019-11-08 03:19:27 +04:00
const not_tommorow: bool = (now = in_24_hrs)
```
2020-01-18 10:56:54 +04:00
<!-- CameLIGO -->
```cameligo group=c
let not_tomorrow: bool = (Current.time = in_24_hrs)
```
<!-- ReasonLIGO -->
```reasonligo group=c
let not_tomorrow: bool = (Current.time == in_24_hrs);
```
2019-11-08 03:19:27 +04:00
<!-- END_DOCUSAURUS_CODE_TABS -->
## Addresses
`address` is a LIGO datatype used for Tezos addresses (tz1, tz2, tz3, KT1, ...).
Here's how you can define an address:
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
2019-12-26 17:21:17 +04:00
```pascaligo group=d
2019-11-08 03:19:27 +04:00
const my_account: address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
```
2020-01-18 10:56:54 +04:00
<!-- CameLIGO -->
```cameligo group=d
let my_account: address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address)
```
<!-- ReasonLIGO -->
```reasonligo group=d
let my_account: address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
```
2019-11-08 03:19:27 +04:00
<!-- END_DOCUSAURUS_CODE_TABS -->
2020-01-13 14:37:10 +04:00
## Signatures
`signature` is a LIGO datatype used for Tezos signature (edsig, spsig).
Here's how you can define a signature:
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
```pascaligo group=e
const my_signature: signature = ("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7": signature);
```
<!-- CameLIGO -->
```cameligo group=e
let my_signature: signature = ("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7": signature)
```
<!-- ReasonLIGO -->
```reasonligo group=e
let my_signature: signature = ("edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7": signature);
```
<!-- END_DOCUSAURUS_CODE_TABS -->
## keys
`key` is a LIGO datatype used for Tezos public key.
Here's how you can define a key:
<!-- DOCUSAURUS_CODE_TABS -->
<!-- Pascaligo -->
```pascaligo group=f
const my_key: key = ("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav": key);
```
<!-- CameLIGO -->
```cameligo group=f
let my_key: key = ("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav": key)
```
<!-- ReasonLIGO -->
```reasonligo group=f
let my_key: key = ("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav": key);
```
2020-01-18 10:56:54 +04:00
<!-- END_DOCUSAURUS_CODE_TABS -->