M
M
morefire05112020-04-13 18:48:42
PHP
morefire0511, 2020-04-13 18:48:42

How to get the number of weeks in a year and for 5 years?

how to display the number of weeks that have passed since my birth for example from this date 2000-09-05

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-04-13
@morefire0511

<?php
$datetime1 = new DateTime('2000-09-05');
$datetime2 = new DateTime('2020-04-13');
$interval = $datetime1->diff($datetime2);
$diff_days = $interval->format('%a');
$diff_weeks = floor($diff_days/7);

echo "days: {$diff_days}\n";
echo "weeks: {$diff_weeks}\n";

//days: 7160
//weeks: 1022

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question