perkes456
perkes456

Reputation: 1181

Converting string to date or getting the current date using Zend PHP Framework 2

I have a controller action in which I fetch the currrent date like following:

    $fullDate=date("Y-m-d");
    $date = strtotime($fullDate);
    $viewModel->setVariable("currentDate",$date);
// Here I would like to pass the variable to the View and then compare it with another date ... 

With the method above I'm getting this when I do var_dump($currentDate);

int(1463587200)

which is not what I was expecting... I need a date in format like this 2016-05-19 (year-month-day)... How can I do this the valid way???

Upvotes: 1

Views: 609

Answers (1)

AnatPort
AnatPort

Reputation: 748

This strtotime is converting your formatted date into a Unix time-stamp. just remove it.

     $fullDate=date("Y-m-d");
     $viewModel->setVariable("currentDate",$fullDate);

you'll be able to compare two dates in this format Y-m-d without converting to time-stamp.

Upvotes: 1

Related Questions