# @patternfly/pfe-datetime

> Datetime element for PFElements

Latest version **1.12.3** (published 2022-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @patternfly/pfe-datetime
pnpm add @patternfly/pfe-datetime
yarn add @patternfly/pfe-datetime
bun add @patternfly/pfe-datetime
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.12.3 |
| Published | 2022-02-01 |
| First published | 2019-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 70.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 396 |
| Maintainers | ctrowbri, dgutride, dlabrecq, patternfly-build, jeff-phillips-18, mturley, mwcz, kylebuch8, realredallen, ktotten, evwilkin, schulj12, castastrophe, nicolethoen, heymp, zhawkins |

## Links

- npm: https://www.npmjs.com/package/@patternfly/pfe-datetime
- Repository: https://github.com/patternfly/patternfly-elements
- Homepage: https://github.com/patternfly/patternfly-elements#readme
- Issues: https://github.com/patternfly/patternfly-elements/issues
- npm.io page: https://npm.io/package/@patternfly/pfe-datetime

## Dependencies (1)

- [@patternfly/pfelement](https://npm.io/package/@patternfly/pfelement.md) ^1.12.3

## Recent versions

- 1.12.3 (latest) — 2022-02-01
- 2.0.0-next.4 (next) — 2022-08-23
- 2.0.0-next.3 — 2022-04-18
- 2.0.0-next.2 — 2022-03-23
- 2.0.0-next.1 — 2022-03-21
- 2.0.0-next.0 — 2022-02-23
- 1.12.2 — 2021-11-16
- 1.12.1 — 2021-11-16
- 1.12.0 — 2021-11-12
- 1.11.2 — 2021-09-29
- 1.11.1 — 2021-09-03
- 1.11.0 — 2021-08-18
- 1.10.1 — 2021-07-12
- 1.10.0 — 2021-07-08
- 1.9.3 — 2021-06-16
- … 52 more at https://npm.io/package/@patternfly/pfe-datetime/versions

## README

# PFElements Datetime Element

This PFElement enables developers to get a lot of the features from the [Intl Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) just by using attributes to set the format of the date and time they'd like to display.

## Usage

### Just the date: January 2, 2006
```html
<pfe-datetime
  datetime="Mon Jan 2 15:04:05 EST 2006"
  format="local"
  day="numeric"
  month="long"
  year="numeric">
  Mon Jan 2 15:04:05 EST 2006
</pfe-datetime>
```

### With time: Monday, Jan 02, 2006, 3:04:05 PM
```html
<pfe-datetime
  datetime="Mon Jan 2 15:04:05 EST 2006"
  format="local"
  weekday="long"
  month="short"
  day="2-digit"
  year="numeric"
  hour="2-digit"
  minute="2-digit"
  second="2-digit">
  Mon Jan 2 15:04:05 EST 2006
</pfe-datetime>
```

### With an en-GB locale: Monday, 02 Jan 2006, 15:04:05
You can use any locale here.
```html
<pfe-datetime
  datetime="Mon Jan 2 15:04:05 EST 2006"
  format="local"
  weekday="long"
  month="short"
  day="2-digit"
  year="numeric"
  hour="2-digit"
  minute="2-digit"
  second="2-digit"
  locale="en-GB">
  Mon Jan 2 15:04:05 EST 2006
</pfe-datetime>
```

### Time adverbial: 13 years ago
```html
<pfe-datetime
  format="relative"
  datetime="Mon Jan 2 15:04:05 EST 2006">
  Mon Jan 2 15:04:05 EST 2006
</pfe-datetime>
```

## Attributes

### datetime (observed)

The value of this should be the same timestamp that you add to the light DOM.

### timestamp (observed)

A unix timestamp that will be converted for use in displaying the appropriate date. You would not use both datetime and timestamp, and the last updated will take precedence.

### format (observed)

The options for type are:
- `local`: Shows a formatted time for the indicated locale if provided
- `relative`: Shows a relative time (1 hour ago, 2 hours until)

### weekday

Possible values: `narrow`, `short`, `long`

### month

Possible values: `numeric`, `2-digit`, `narrow`, `short`, `long`

### day

Possible values: `numeric`, `2-digit`

### year

Possible values: `numeric`, `2-digit`

### hour

Possible values: `numeric`, `2-digit`

### minute

Possible values: `numeric`, `2-digit`

### second

Possible values: `numeric`, `2-digit`

## Test

    npm run test

## Build

    npm run build

## Demo

From the PFElements root directory, run:

    npm start

## Code style

Datetime (and all PFElements) use [Prettier][prettier] to auto-format JS and JSON.  The style rules get applied when you commit a change.  If you choose to, you can [integrate your editor][prettier-ed] with Prettier to have the style rules applied on every save.

[prettier]: https://github.com/prettier/prettier/
[prettier-ed]: https://prettier.io/docs/en/editors.html
[web-component-tester]: https://github.com/Polymer/web-component-tester

---
_Source: https://npm.io/package/@patternfly/pfe-datetime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
