Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL TIMESTAMP DEFAULT CURRENT TIMESTAMP: How to remove miliseconds?

Problem: When I print time in my HTML code it shows like this: 2020-05-31 03:29:50.617897

Code: https://i.sstatic.net/HTIXy.png

Question: How to get rid of decimal .617897? Thank you. I'm new to programming.

like image 837
Bruce Salcedo Avatar asked Apr 18 '26 13:04

Bruce Salcedo


1 Answers

In Postgres, you can use date_trunc():

select date_trunc('second', current_timestamp)
like image 129
Gordon Linoff Avatar answered Apr 20 '26 02:04

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!