Is there a way to convert text over time in postgresql?

Is there a way to convert text to time type? The code in postgresql is as below:

to_char(localtimestamp(0),'HH24:mi:SS') 

so i get a value like 15:15:20 , but this type is varchar (or text).
How to do to get a value in type time ?

Thanks!

+4
source share
1 answer
 SELECT TO_TIMESTAMP('15:15:20', 'HH24:MI:SS')::TIME 

Please note that your request (which returns local time) can be rewritten as

 SELECT LOCALTIME 

which will return TIME

+13
source

All Articles