public function setCreatedAtAttribute($createdAt)
    {
        if (!$createdAt) {
            return;
        }

        if (!$createdAt instanceof DateTime) {
            $createdAt = Carbon::parse($createdAt);
        }

        $timestamp = $createdAt->format('U');
        $timestamp = 30 * round($timestamp / 30);

        $date = Carbon::createFromFormat('U', $timestamp)->toDateTimeString();

        $this->attributes['created_at'] = $date;

        return $date;
    }
public function setCreatedAtAttribute($createdAt)
    {
        if (!$createdAt) {
            return;
        }

        if (!$createdAt instanceof DateTime) {
            $createdAt = Carbon::parse($createdAt);
        }

        $timestamp = $createdAt->format('U');
        $timestamp = 30 * round($timestamp / 30);

        $date = Carbon::createFromFormat('U', $timestamp)->toDateTimeString();

        $this->attributes['created_at'] = $date;

        return $date;
    }
public function setCreatedAtAttribute ( $ createdAt ) { if ( ! $ createdAt ) { return ; } if ( ! $ createdAt instanceof DateTime ) { $ createdAt = Carbon :: parse ( $ createdAt ) ; } $ timestamp = $ createdAt -> format ( 'U' ) ; $ timestamp = 30 * round ( $ timestamp / 30 ) ; $ date = Carbon :: createFromFormat ( 'U' , $ timestamp ) -> toDateTimeString ( ) ; $ this -> attributes [ 'created_at' ] = $ date ; return $ date ; }
Round the created at value into intervals of 30 seconds.

@param string $createdAt

@return string|void
Round the created at value into intervals of 30 seconds .