[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [PHP] dato bug ???



Kristian Nørgaard wrote:
Midt mellem de rigtige datoer udskrives en søndag: 30/10-2005

Nogen der kan forklare / har hørt om det problem?

Jeg havde ikke hørt om det, men har en forklaring. Det er sommertidsafslutningen, der snyder koden. Af en eller anden grund omregner "next monday" til X gange 24 timer og lægger dem til. Her er lidt kode, der demonstrerer det lidt tydeligere, og jeg har inkluderet en workaround, for det viser sig at "+ X days" fungerer efter hensigten.


<?php

header("Content-Type: text/plain");

function nm($dato)
{
  $dato = strtotime($dato);
  $w = date("w", $dato);
  $w = $w==0?7:$w;
  $adddays = 8-$w;
  echo "Dato: " . date("D d/m-Y H:i:s", $dato) . " - ";
  echo date("D d/m-Y H:i:s", strtotime("+ $adddays days", $dato)). " ";
  echo date("D d/m-Y H:i:s", strtotime("next monday", $dato)) . "\n";
}

nm("15 october 2005");
nm("22 october 2005");
nm("29 october 2005");
nm("5 november 2005");

?>

Med venlig hilsen

Ole

 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-11-01, 02:01 CET [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *