> This page location: Date Functions > TIMEOFDAY
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL TIMEOFDAY() Function

**Summary**: in this tutorial, you will learn how to use the PostgreSQL `TIMEOFDAY()` function to retrieve the current date and time as a formatted string.

## Introduction to the PostgreSQL TIMEOFDAY() function

The `TIMEOFDAY()` function returns the [current date and time](https://neon.com/postgresql/postgresql-date-functions/postgresql-current_timestamp) as a formatted string.

Here's the syntax of the `TIMEOFDAY()` function:

```sql
TIMEOFDAY()
```

The function does not have any parameters and returns the current date and time as a string.

Note that the `TIMEOFDAY()` function returns the same result as the `CLOCK_TIMESTAMP()` function but in the text string.

## PostgreSQL TIMEOFDAY() function examples

Let's take some examples of using the `TIMEOFDAY()` function.

### 1) Basic TIMEOFDAY() function example

The following example uses the `TIMEOFDAY()` function to retrieve the current date and time as a string:

```text
              timeofday
-------------------------------------
 Wed Mar 20 10:20:10.108369 2024 -07
(1 row)
```

The output shows the date, time, and timezone.

### 2) Formatting the output

If you want a specific format, you can cast the result of the `TIMEOFDAY()` function into a timestamp and use the `to_char()` function to achieve the desired format:

```sql
SELECT
  to_char(
    timeofday():: timestamp,
    'YYYY-MM-DD HH24:MI:SS'
  ) current_time;
```

Output:

```text
    current_time
---------------------
 2024-03-20 10:26:57
(1 row)
```

## Summary

- Use the `TIMEOFDAY()` function to obtain the current date and time as a formatted string.

---

## Related docs (Date Functions)

- [AGE](https://neon.com/postgresql/postgresql-date-functions/postgresql-age)
- [AT TIME ZONE Operator](https://neon.com/postgresql/postgresql-date-functions/postgresql-at-time-zone)
- [CLOCK_TIMESTAMP](https://neon.com/postgresql/postgresql-date-functions/postgresql-clock_timestamp)
- [CURRENT_DATE](https://neon.com/postgresql/postgresql-date-functions/postgresql-current_date)
- [CURRENT_TIME](https://neon.com/postgresql/postgresql-date-functions/postgresql-current_time)
- [CURRENT_TIMESTAMP](https://neon.com/postgresql/postgresql-date-functions/postgresql-current_timestamp)
- [DATE_PART](https://neon.com/postgresql/postgresql-date-functions/postgresql-date_part)
- [DATE_TRUNC](https://neon.com/postgresql/postgresql-date-functions/postgresql-date_trunc)
- [EXTRACT](https://neon.com/postgresql/postgresql-date-functions/postgresql-extract)
- [ISFINITE](https://neon.com/postgresql/postgresql-date-functions/postgresql-isfinite)
- [JUSTIFY_DAYS](https://neon.com/postgresql/postgresql-date-functions/postgresql-justify_days)
- [JUSTIFY_HOURS](https://neon.com/postgresql/postgresql-date-functions/postgresql-justify_hours)
- [JUSTIFY_INTERVAL](https://neon.com/postgresql/postgresql-date-functions/postgresql-justify_interval)
- [LOCALTIME](https://neon.com/postgresql/postgresql-date-functions/postgresql-localtime)
- [LOCALTIMESTAMP](https://neon.com/postgresql/postgresql-date-functions/postgresql-localtimestamp)
- [MAKE_DATE](https://neon.com/postgresql/postgresql-date-functions/postgresql-make_date)
- [MAKE_INTERVAL](https://neon.com/postgresql/postgresql-date-functions/postgresql-make_interval)
- [MAKE_TIME](https://neon.com/postgresql/postgresql-date-functions/postgresql-make_time)
- [NOW](https://neon.com/postgresql/postgresql-date-functions/postgresql-now)
- [PG_SLEEP](https://neon.com/postgresql/postgresql-date-functions/postgresql-pg_sleep)
- [STATEMENT_TIMESTAMP](https://neon.com/postgresql/postgresql-date-functions/postgresql-statement_timestamp)
- [TO_DATE](https://neon.com/postgresql/postgresql-date-functions/postgresql-to_date)
- [TO_TIMESTAMP](https://neon.com/postgresql/postgresql-date-functions/postgresql-to_timestamp)
