Skip to content
Back to skills

Date Format

ASecurity

Formats dates using date-fns patterns. Supports relative time ("3 hours ago"), toggling between relative and absolute display, and auto-refreshing relative times.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 27, 2026
developmenttypescriptgo

Works with

  • cursor
  • cli

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add reaviz/skills --skill date-format --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Date Format?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Date Format
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/reaviz-date-format/badge)](https://www.skillsdirectory.com/skills/reaviz-date-format)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# DateFormat

Formats dates using date-fns patterns. Supports relative time ("3 hours ago"), toggling between relative and absolute display, and auto-refreshing relative times.

## Import

```tsx
import { DateFormat } from 'reablocks';
```

## DateFormat Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `date` | `Date \| string \| number \| null` | — | The date to format |
| `format` | `string` | `'MM/dd/yy hh:mm:ss a'` | date-fns format string |
| `fromNow` | `boolean` | — | Use relative time display |
| `addSuffix` | `boolean` | `true` | Add suffix to relative time (e.g. "ago") |
| `includeSeconds` | `boolean` | `false` | Include seconds in relative time |
| `allowToggle` | `boolean` | `false` | Allow clicking to toggle relative/absolute |
| `cacheKey` | `string` | — | localStorage key to persist user's toggle preference |
| `emptyMessage` | `string` | `'N/A'` | Displayed when date is null/undefined |
| `className` | `string` | — | Additional CSS classes |
| `theme` | `DateFormatTheme` | — | Per-instance theme override |

## Basic Usage

```tsx
<DateFormat date={new Date()} />
```

## Relative Time

```tsx
<DateFormat date={someDate} fromNow />
{/* Renders: "3 hours ago", "2 days ago", "now" (if < 30 seconds) */}
```

Relative time auto-refreshes: every 60s for < 1 hour, every hour for < 1 day.

## Toggle Between Relative and Absolute

```tsx
<DateFormat date={new Date()} fromNow allowToggle />
{/* Click to toggle between "2 minutes ago" and "04/15/26 02:30:00 PM" */}
```

## String Dates

```tsx
<DateFormat date="2022-05-25T16:03:12.2085" />
```

## Empty State

```tsx
<DateFormat date={null} />                       {/* "N/A" */}
<DateFormat date={null} emptyMessage="No date" /> {/* "No date" */}
```

## DateFormatTheme Interface

```typescript
interface DateFormatTheme {
  base: string;         // Base styles
  interactive: string;  // Styles when allowToggle is true (cursor-pointer, hover:underline)
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.