---
schema_version: "1"
id: c0d8668a97ffd2247cb900c3377df8e99de2a589e9c6430c0ff7c9ac83beb88e
title: isBefore()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/aura-platform/guides/aura/ref-jsapi/ref-jsapi-auralocalizationservice-isbefore.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/ref-jsapi-auralocalizationservice-isbefore.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5c989d4030e2da6017fa45596db96033c45c2a46d0eb6d0b1be9745febefe1f1
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# isBefore()

Checks if `date1` is before `date2`.

## Signature

`isBefore(string | number | Date date1, string | number | Date date2, string unit)`

## Parameters

**_date1_:** Type: `string | number | Date`. A datetime string in ISO8601 format, or a timestamp in milliseconds, or a `Date` object.

**_date2_:** Type: `string | number | Date`. A datetime string in ISO8601 format, or a timestamp in milliseconds, or a `Date` object.

**_unit_:** Type: `string`. A datetime unit. Options are 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', or 'millisecond'.

## Returns

**Type: `boolean`**

Returns `true` if `date1` is before `date2`, or `false` otherwise.

## Sample Code

```javascript
var date = new Date();
var day = $A.localizationService.endOf(date, 'day');
// Returns true, since date is before day
$A.localizationService.isBefore(date, day);
```

