Muhammad Almas Khan
Muhammad Almas Khan

Reputation: 1

subtract date in 2016 from current date in php

I want to subtract one date in 2016 from current date using php and display day.How i do this using php . can anyone help me . please give suggestion

Any ideas how I can accomplish this?

Upvotes: 0

Views: 46

Answers (1)

ben
ben

Reputation: 470

check this code snippet

<?php
    $date = new DateTime();
    $date->modify('-1 day');
    echo $date->format('Y-m-d');
?>

Based on the number of day you need to put the parameter $date->modify('-{NoofdaystoSubstract} day');

Upvotes: 1

Related Questions