> For the complete documentation index, see [llms.txt](https://atomframework.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atomframework.gitbook.io/docs/misc/moment.md).

# Moment

Sometimes you need to manage date. That's why we developed Moment. Moment allows you to manage dates simply.

## Basic Usage

First you need to initialize Moment using the `moment` function:

```php
$today = moment('today');
$yesterday = moment('yesterday');
$tomorrow = moment('tomorrow');
```

Here:

* `$today` equals to today `timestamps`
* `$yesterday` equals to yesterday `timestamps`
* `$tomorrow` equals to tomorrow `timestamps`

If you don't pass a day as argument to the `moment` function, the today timestamps will be returned.

### Adding date

Since you have initialized a moment, you can add value to this moment using the `add` function. Here is an example:

```php
$today = moment('today');
$tomorrow = $today->add('1 day');
$next_month = $today->add('1 month');
$next_year = $today->add('1 year');
```

### Removing date

You can also remove value to the current date with the `remove` function:

```php
$today = moment();
$yesterday = $today->remove('1 day');
$previous_month = $today->remove('1 month');
$previous_year = $today->remove('1 year');
```

### Getting Timestamps Value

If you want to get the timestamps value of an moment, use the `timestamp` function:

```php
$tomorrow = moment('tomorrow');
echo $tomorrow->timestamp();
```

## Formatting

You can get a formatted date of an moment using the `format` function:

```php
$today = moment();

$formatted = $today->format();

//or
$formatted = $today->format('Y-m-d H:i:s');

echo $formatted;
```
