> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DateUtils

[localhost link]: http://localhost:3000/docs/4/app-studio/reference/services/lightning.DateUtils

[mintlify link]: https://doc.lucidworks.com/docs/4/app-studio/reference/services/lightning.DateUtils.md

[old doc.lw link]: https://doc.lucidworks.com/app-studio/4.2/1224.md

> [card] Key questions to get you started
>
> Powered by Lucidworks Agent Studio

## Description

Twigkit service for useful date functions

## Methods

### dateSortResults(results, dateField, oldestFirst)

Sort results array by date

##### Parameters

| Param | Type | Details |
| - | - | - |
| results | mixed | Array of results from response |
| dateField | string | Result field to use for ordering |
| oldestFirst | boolean | If true the results will be order from oldest to newest |

##### Returns

| | |
| - | - |
| mixed | Sorted array of results |

### groupByDateRanges(results, dateField, groupBy)

Group results into date ranges, used for the timeline

##### Parameters

| Param | Type | Details |
| - | - | - |
| results | mixed | Sorted array of results |
| dateField | string | Result field to use for ordering |
| groupBy | string | Optionally specify how to group the results, by default it tries to get the best fit |

##### Returns

| | |
| - | - |
| mixed | Array of grouped results |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.