Skip to content
Advertisement

{Carbon} Convert time in HH:MM:SS format into seconds in Laravel?

I want to convert the time which I got from $scheduleTime = Carbon::createFromTimestampUTC($scheduleTimestamp)->toTimeString(); which is currently giving me 07:32:40 now I want to convert it into seconds only using Carbon library is this possible to do so if yes then how?

Advertisement

Answer

well, its there in carbon itself just use secondsSinceMidnight() and you are good to go.

 $scheduleTimeSeconds = Carbon::createFromTimestampUTC($scheduleTimestamp)->secondsSinceMidnight();
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement