Skip to main content
PHP Blog

Back to all posts

How to Format Date As 'Dd-Mm-Yyyy' From Bigint Value In Postgresql?

Published on
3 min read
How to Format Date As 'Dd-Mm-Yyyy' From Bigint Value In Postgresql? image

Best Tools to Format Dates from Bigint in PostgreSQL to Buy in October 2025

1 Full-Stack Web Development with TypeScript 5: Craft modern full-stack projects with Bun, PostgreSQL, Svelte, TypeScript, and OpenAI

Full-Stack Web Development with TypeScript 5: Craft modern full-stack projects with Bun, PostgreSQL, Svelte, TypeScript, and OpenAI

BUY & SAVE
$36.26
Full-Stack Web Development with TypeScript 5: Craft modern full-stack projects with Bun, PostgreSQL, Svelte, TypeScript, and OpenAI
2 PostgreSQL: A Practical Guide for Developers and Data Professionals

PostgreSQL: A Practical Guide for Developers and Data Professionals

BUY & SAVE
$5.99
PostgreSQL: A Practical Guide for Developers and Data Professionals
3 Procedural Programming with PostgreSQL PL/pgSQL: Design Complex Database-Centric Applications with PL/pgSQL

Procedural Programming with PostgreSQL PL/pgSQL: Design Complex Database-Centric Applications with PL/pgSQL

BUY & SAVE
$39.91
Procedural Programming with PostgreSQL PL/pgSQL: Design Complex Database-Centric Applications with PL/pgSQL
4 Beginning PHP and PostgreSQL 8: From Novice to Professional (Beginning: From Novice to Professional)

Beginning PHP and PostgreSQL 8: From Novice to Professional (Beginning: From Novice to Professional)

  • AFFORDABLE PRICES FOR QUALITY USED BOOKS IN GOOD CONDITION.
  • ECO-FRIENDLY CHOICE: REDUCE WASTE BY BUYING PRE-LOVED BOOKS.
  • FAST SHIPPING ENSURES QUICK DELIVERY FOR EAGER READERS.
BUY & SAVE
$35.25 $49.99
Save 29%
Beginning PHP and PostgreSQL 8: From Novice to Professional (Beginning: From Novice to Professional)
5 DEUOTION T-post Clips Tool, Fixing Fence Clip and Wire Steel Bender T-post Handheld Twisting Tool, Multi Functional Bender

DEUOTION T-post Clips Tool, Fixing Fence Clip and Wire Steel Bender T-post Handheld Twisting Tool, Multi Functional Bender

  • SPEED UP FENCE INSTALLATION WITH RAPID T-POST CLIP SECURING!

  • USER-FRIENDLY, PORTABLE DESIGN FOR PROS AND DIYERS ALIKE!

  • DURABLE, HIGH-QUALITY STEEL TOOL BUILT TO LAST IN ALL CONDITIONS!

BUY & SAVE
$16.99
DEUOTION T-post Clips Tool, Fixing Fence Clip and Wire Steel Bender T-post Handheld Twisting Tool, Multi Functional Bender
6 Mastering PostgreSQL for Developers: Building Fast, Secure, and Scalable Apps

Mastering PostgreSQL for Developers: Building Fast, Secure, and Scalable Apps

BUY & SAVE
$6.77
Mastering PostgreSQL for Developers: Building Fast, Secure, and Scalable Apps
7 PostgreSQL for Python Web Development with Flask: A Practical Guide to Building Database-Driven Web Applications

PostgreSQL for Python Web Development with Flask: A Practical Guide to Building Database-Driven Web Applications

BUY & SAVE
$7.99
PostgreSQL for Python Web Development with Flask: A Practical Guide to Building Database-Driven Web Applications
8 Century Drill & Tool 72898 Post Level

Century Drill & Tool 72898 Post Level

  • HANDS-FREE MAGNETIC AND STRAP DESIGN FOR ULTIMATE CONVENIENCE.
  • VERSATILE FOR INSTALLATION ON POSTS, POLES, AND VARIOUS STRUCTURES.
  • TRIPLE VIALS ENSURE FAST, ACCURATE LEVELING FROM EVERY ANGLE.
BUY & SAVE
$11.98
Century Drill & Tool 72898 Post Level
9 Lind Kitchen 2PCS High-tensile Wire Tool Twisting Too Fencing Tool Wire Twister Multi-Functional Bender for Fixing Fence Wire and Wire Clip

Lind Kitchen 2PCS High-tensile Wire Tool Twisting Too Fencing Tool Wire Twister Multi-Functional Bender for Fixing Fence Wire and Wire Clip

  • DURABLE STEEL CONSTRUCTION PREVENTS RUST, ENSURING LONG-LASTING USE.
  • VERSATILE HOLE DIAMETERS SIMPLIFY WIRE HANDLING, REDUCING HAND FATIGUE.
  • COMPACT DESIGN ALLOWS FOR EASY TRANSPORT, BOOSTING WORK EFFICIENCY.
BUY & SAVE
Lind Kitchen 2PCS High-tensile Wire Tool Twisting Too Fencing Tool Wire Twister Multi-Functional Bender for Fixing Fence Wire and Wire Clip
+
ONE MORE?

In PostgreSQL, you can convert a bigint value representing a timestamp into a formatted date string using the TO_TIMESTAMP function along with the TO_CHAR function.

First, you need to cast the bigint value to a timestamp using the TO_TIMESTAMP function. For example, if your bigint value is stored in a column named "timestamp_column" in a table called "example_table", you can convert it to a timestamp like this:

TO_TIMESTAMP(example_table.timestamp_column)

Next, you can use the TO_CHAR function to format the timestamp as 'dd-mm-yyyy'. The 'dd-mm-yyyy' format specifier represents the day, month, and year in the desired order.

Here is an example query that converts a bigint value to a formatted date string:

SELECT TO_CHAR(TO_TIMESTAMP(example_table.timestamp_column), 'DD-MM-YYYY') AS formatted_date FROM example_table;

This query will return the bigint value from the "timestamp_column" column as a formatted date string in the 'dd-mm-yyyy' format.

What is the function to add days to a date in PostgreSQL?

In PostgreSQL, you can use the + operator to add days to a date. Here is an example of how to add 7 days to a date:

SELECT '2023-01-15'::date + INTERVAL '7 days';

This will return 2023-01-22, which is the date 7 days after 2023-01-15.

How to extract day from bigint value in PostgreSQL?

To extract the day from a bigint value in PostgreSQL, you can use the TO_TIMESTAMP function to convert the bigint value to a timestamp and then use the EXTRACT function to extract the day from the timestamp. Here's an example query:

SELECT EXTRACT(DAY FROM TO_TIMESTAMP(your_bigint_column / 1000)) AS day FROM your_table;

In this query, replace your_bigint_column with the name of the column containing the bigint value and your_table with the name of your table. The / 1000 division is used to convert the bigint value to seconds (assuming the bigint value represents Unix timestamp in milliseconds).

This query will extract the day from the timestamp converted from the bigint value in the specified column.

How to Format date in PostgreSQL?

In PostgreSQL, you can format a date using the to_char() function.

Here is an example of how to format a date in PostgreSQL:

SELECT to_char(current_date, 'YYYY-MM-DD');

In this example, we are formatting the current date to display in the format YYYY-MM-DD. You can customize the formatting according to your needs by changing the format string inside the to_char() function.

Here are some common format strings you can use with to_char():

  • YYYY : Year
  • MM : Month
  • DD : Day
  • HH : Hour
  • MI : Minute
  • SS : Second

You can combine these format strings and add separators like -, /, or , to format the date in the desired way.