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

# PostgreSQL TIMEOFDAY() Function

**Info:** The TIMEOFDAY() function works the same way on any PostgreSQL database, so you can apply what you learn here wherever you run Postgres. If you're an enterprise team building for the AI era, [Lakebase](https://www.databricks.com/product/lakebase) delivers managed Postgres with the performance, security, and native Lakehouse integration you need. If you're a developer or startup who needs to ship quickly and scale without friction, [Neon](https://neon.com) gives you the fastest path from idea to production on Postgres.

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