---
schema_version: "1"
id: c18bf20bfd28a2ca9079279e4f47cf4959165f1ba95adbe33bf45f6b45c1ee64
title: endOf()
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-endof.md
canonical_url: https://developer.salesforce.com/docs/platform/aura-platform/guide/ref-jsapi-auralocalizationservice-endof.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 43f582ecda140dbdfd767b171537044865152e7cdb29991724406a8fba906696
products:
  - Lightning Aura Components Developer Guide
  - Platform Developer Content
---

# endOf()

Returns a date that is the end of a unit of time for the given date.

## Signature

`endOf(string | number | Date date, string unit)`

## Parameters

**_date_:** 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', or 'second'.

## Returns

**Type: `Date`** A JavaScript `Date` object. If a unit is not provided, returns a parsed date.

## Sample Code

```javascript
var date = new Date();
// Returns the time at the end of the day
// in the format "Fri Oct 09 2015 23:59:59 GMT-0700 (PDT)"
var day = $A.localizationService.endOf(date, 'day');
```

