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

# @angular-ru/cdk/date

* `toTimestamp`

```typescript
import {toTimestamp} from '@angular-ru/cdk/date';

const date: string = toTimestamp('5.07.2019 00:00', 'yyyy-MM-dd HH:mm:ss');
expect(date).toEqual('2019-07-05 00:00:00');
```

* `dateStringToDate`

```typescript
import {dateStringToDate} from '@angular-ru/cdk/date';

const date = '11.12.202018 15:41:37';
expect(dateStringToDate(date).getFullYear()).toEqual(new Date().getFullYear());
```

* `isToday`
* `toUnix`
* `toFormat`
* `toISOString`
* `toUtc`
* `toFormatDateTime`
* `isDateValid`
* `toMilliseconds`

```typescript
import {toMilliseconds} from '@angular-ru/cdk/date';

it(`toMilliseconds`, () => {
  expect(toMilliseconds(1599485851)).toEqual(1599485851000);
  expect(toMilliseconds('1599485851')).toEqual(1599485851000);
  expect(toMilliseconds(new Date(0))).toEqual(0);
});
```

* `getToday` - current date from `00:00`

```typescript
getToday(); // type Date -> [12.01.2020 00:00]
```

* `startOfDay`
* `endOfDay`

```typescript
import {shiftDate} from '@angular-ru/cdk/date';

const someDate: Date = new Date('2020-01-01, 16:01:00');
it('should correctly shift date', (): void => {
  const expectDate: Date = shiftDate(
    {
      years: 1,
      months: 2,
      days: 3,
      hours: 4,
      minutes: 5,
    },
    someDate,
  );
  expect(expectDate.toLocaleString()).toBe('04.03.2021, 20:06:00');
  expect(expectDate.getMilliseconds()).toBe(8);
});
```

```typescript
import {toISOStringWithoutTimezone} from '@angular-ru/cdk/date';

const timezoneOffSet: number = new Date().getTimezoneOffset();
it('should correctly parse "2020-01-01T00:00:00.000Z"', (): void => {
  const someDate: Date = new Date('2020-01-01T00:00:00.000Z');
  const expectDate: string = toISOStringWithoutTimezone(someDate);
  if (timezoneOffSet === -180) {
    expect(expectDate).toBe('2020-01-01T03:00:00.000');
  }
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://angular-ru.gitbook.io/sdk/cdk/date.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
