Skip to content

Commit

Permalink
DOC-326: Add time::from::uuid and time::from::ulid (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ekwuno authored Jan 9, 2025
1 parent 00e840f commit c5ad332
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/content/doc-surrealql/functions/database/time.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ time::yday();
<td scope="row" data-label="Function"><a href="#timefromunix"><code>time::from::unix()</code></a></td>
<td scope="row" data-label="Description">Calculates a datetime based on the seconds since January 1, 1970 0:00:00 UTC.</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#timefromulid"><code>time::from::ulid()</code></a></td>
<td scope="row" data-label="Description">Calculates a datetime based on the ULID.</td>
</tr>
<tr>
<td scope="row" data-label="Function"><a href="#timefromuuid"><code>time::from::uuid()</code></a></td>
<td scope="row" data-label="Description">Calculates a datetime based on the UUID.</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -646,4 +654,40 @@ RETURN time::from::unix(1000);
d"1970-01-01T00:16:40Z"
```

<br /><br />
<br />

## `time::from::ulid`

The `time::from::ulid` function calculates a datetime based on the ULID.

```surql title="API DEFINITION"
time::from::ulid(ulid) -> datetime
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement:

```surql
RETURN time::from::ulid("01JH5BBTK9FKTGSDXHWP5YP9TQ");
d'2025-01-09T10:57:03.593Z'
```

<br />

## `time::from::uuid`

The `time::from::uuid` function calculates a datetime based on the UUID.

```surql title="API DEFINITION"
time::from::uuid(uuid) -> datetime
```

The following example shows this function, and its output, when used in a [`RETURN`](/docs/surrealql/statements/return) statement:

```surql
RETURN time::from::uuid(u'01944ab6-c1e5-7760-ab6a-127d37eb1b94');
d'2025-01-09T10:57:58.757Z'
```

<br />

0 comments on commit c5ad332

Please sign in to comment.