---
title: WidgetDate
description: Date element shown in a widget.
---

Date element shown in a widget.

A date shown in a widget. Dates will update periodically when shown in a widget.

You do not create instances of this element directly. Instead you should call `addDate()` on an instance of a `ListWidget`.

## Properties

### date

Date to show in a widget.

```typescript
date: Date
```

### font

Font and text size of the text.

```typescript
font: Font
```

### lineLimit

Maximum number of lines.

```typescript
lineLimit: number
```

Maximum number of lines to display. The limit is disabled when the value is 0 or less. Defaults to 0.

### minimumScaleFactor

Minimum amount the text scales down to.

```typescript
minimumScaleFactor: number
```

Sets the minimum amount that text scales down to fit in the available space. For example, a text with a minimum scale factor of 0.5 allows the widget to draw the text in a font size half the size of the actual font. The scale factor should be a fraction between 0 and 1, both inclusive. Defaults to 1.

### shadowColor

Color of the shadow.

```typescript
shadowColor: Color
```

Sets the color of the shadow cast by the text. The `shadowRadius` property must have a value greater than zero for this property to have an effect. Defaults to black.

### shadowOffset

Offset of the shadow.

```typescript
shadowOffset: Point
```

Sets the offset of the shadow cast by the text. The `shadowRadius` property must have a value greater than zero for this property to have an effect. Defaults to (0, 0).

### shadowRadius

Size of the shadow.

```typescript
shadowRadius: number
```

Sets the size of the shadow cast by the text. Defaults to 0.

### textColor

Color of the text.

```typescript
textColor: Color
```

### textOpacity

Opacity of the text.

```typescript
textOpacity: number
```

Opacity of the text. This must be a value between 0 and 1. Defaults to 1.

### url

URL to open.

```typescript
url: string
```

The URL will be opened when the text is tapped. This is only supported in medium and large widgets. Small widgets can only have a single tap target, which is specified by the `url` on the widget.

## Methods

<span id="-applydatestyle" class="api-anchor"></span>

### applyDateStyle()

Display entire date.

```typescript
applyDateStyle()
```

Example output:
    June 3, 2019

This is the default.

<span id="-applyoffsetstyle" class="api-anchor"></span>

### applyOffsetStyle()

Display date as offset from now.

```typescript
applyOffsetStyle()
```

Example output:
    +2 hours
    -3 months

<span id="-applyrelativestyle" class="api-anchor"></span>

### applyRelativeStyle()

Display date as relative to now.

```typescript
applyRelativeStyle()
```

Example output:
    2 hours, 23 minutes
    1 year, 1 month

<span id="-applytimerstyle" class="api-anchor"></span>

### applyTimerStyle()

Display date as timer counting from now.

```typescript
applyTimerStyle()
```

Example output:
   2:32
   36:59:01

<span id="-applytimestyle" class="api-anchor"></span>

### applyTimeStyle()

Display time component of the date.

```typescript
applyTimeStyle()
```

Example output:
    11:23PM

<span id="-centeraligntext" class="api-anchor"></span>

### centerAlignText()

Center aligns the text.

```typescript
centerAlignText()
```

Specifies that text should be center aligned.

This does not affect texts placed in stacks. Use spacers instead when aligning text in stacks. To align the text in the center of a horizontal stack, you should place a spacer both before and after the text.

<span id="-leftaligntext" class="api-anchor"></span>

### leftAlignText()

Left aligns the text.

```typescript
leftAlignText()
```

Specifies that text should be left aligned. This is the default.

This does not affect texts placed in stacks. Use spacers instead when aligning text in stacks. To align the text to left right in a horizontal stack, you should place a spacer after the text.

<span id="-rightaligntext" class="api-anchor"></span>

### rightAlignText()

Right aligns the text.

```typescript
rightAlignText()
```

Specifies that text should be right aligned.

This does not affect texts placed in stacks. Use spacers instead when aligning text in stacks. To align the text to the right in a horizontal stack, you should place a spacer before the text.