Subtract 1 day with PHP

后端 未结 10 783
我在风中等你
我在风中等你 2020-11-28 06:52

I\'m trying to take a date object that\'s coming out of my Drupal CMS, subtract one day and print out both dates. Here\'s what I have

$date_raw = $messageno         


        
10条回答
  •  旧时难觅i
    2020-11-28 07:21

    Not sure why your current code isn't working but if you don't specifically need a date object this will work:

    $first_date = strtotime($date_raw);
    $second_date = strtotime('-1 day', $first_date);
    
    print 'First Date ' . date('Y-m-d', $first_date);
    print 'Next Date ' . date('Y-m-d', $second_date);
    

提交回复
热议问题