Format Unix Time to display Data only

Asked

Viewed 113 times

2

Good afternoon, am with a problem where I need to remove the time or set the final time always to 23:59:59

if($form)
    {
        $start = new \DateTime($form['startDate']);
        $start = $start->format('U');

        $end = new \DateTime($form['endDate']);
        $end = $end->format('U');
    }

    $start = isset($start) ? $start : (time() - ((60*60*24)*30));
    $end   = isset($end) ? $end : time();

Does anyone know how to format Unix Time?

  • mktime() or strtotime() do not resolve? http://php.net/manual/en/function.date.php

1 answer

4


Instead of using the format U, which is precisely the Unix Timestamp, can use Y-m-d:

$start = $start->format('Y-m-d');

See how Format the date in PHP.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.