3 online now
Customer reviews
Customers using it now
★★★★★
4,8 · 1.263+ average rating
Verified customer
Leave a review
Need help?

Talk to our team on WhatsApp and we will help you move forward.

💬
Minike Tools Banner

Date Calculator

Date Calculator

Add or subtract days, weeks, months and years from a date.

Gratis ate 10 MB por arquivo100 MB por enviosem anuncio antes do limite
$titulo = 'Calculadora de Datas'; $descricao = 'Some ou subtraia dias, meses ou anos de uma data'; $palavrasChave = 'calcular datas, somar dias, subtrair dias, calendario'; $data = date('Y-m-d'); $operacao = 'somar'; $valor = 0; $unidade = 'dias'; $resultado = null; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $data = $_POST['data'] ?? date('Y-m-d'); $operacao = $_POST['operacao'] ?? 'somar'; $valor = intval($_POST['valor'] ?? 0); $unidade = $_POST['unidade'] ?? 'dias'; $dataObj = new DateTime($data); if ($operacao === 'somar') { switch ($unidade) { case 'dias': $dataObj->add(new DateInterval("P{$valor}D")); break; case 'meses': $dataObj->add(new DateInterval("P{$valor}M")); break; case 'anos': $dataObj->add(new DateInterval("P{$valor}Y")); break; case 'semanas': $dataObj->add(new DateInterval("P" . ($valor * 7) . "D")); break; } } else { switch ($unidade) { case 'dias': $dataObj->sub(new DateInterval("P{$valor}D")); break; case 'meses': $dataObj->sub(new DateInterval("P{$valor}M")); break; case 'anos': $dataObj->sub(new DateInterval("P{$valor}Y")); break; case 'semanas': $dataObj->sub(new DateInterval("P" . ($valor * 7) . "D")); break; } } $resultado = [ 'data_original' => $data, 'data_resultado' => $dataObj->format('Y-m-d'), 'data_formatada' => $dataObj->format('d/m/Y'), 'dia_semana' => $dataObj->format('l'), 'dias_uteis' => calcularDiasUteis(new DateTime($data), $dataObj, $operacao) ]; } function calcularDiasUteis($dataInicio, $dataFim, $operacao) { $diasUteis = 0; $current = clone $dataInicio; $interval = $operacao === 'somar' ? 1 : -1; while ($current != $dataFim) { $current->modify(($interval > 0 ? '+' : '-') . '1 day'); $diaSemana = $current->format('N'); if ($diaSemana < 6) { $diasUteis += $interval; } } return abs($diasUteis); } ?> - Minike Ferramentas

Recommended next step

Keep this result working for you

Minike connects the tool you are using with the product most likely to generate recurring value.

Prices shown for Brazil and US positioning. Current local checkout charges BRL until the international gateway is enabled.
Share this tool
✓ Link copiado!