Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Apex's avatar
Level 1

Convert to timestamp

I am trying to convert following string into timestamp string column: Tue Sep 03 01:21:59 UTC 2019 required format: 2019-09-03 01:21:59

in REDSHIFT

Any idea how to do that?

I have tried interval, integer, epoch, date_parse etc but its not working

0 likes
4 replies
Apex's avatar
Level 1

my string is "Tue Sep 03 01:21:59 UTC 2019"

I have to do this in redshift/postresql, the above solution is in php :|

1 like
Nakov's avatar

@apex This is what I did and it worked fine. The result is UTC anyway, so I don't know if there is a format that can be used to replace that. But I am just removing that part from the String and then formatting it:

// imports at the top
use Carbon\Carbon;
use Illuminate\Support\Str;

Carbon::createFromFormat('D M d H:i:s Y', Str::replaceFirst('UTC ', '', 'Tue Sep 03 01:21:59 UTC 2019'))

Please or to participate in this conversation.