Kopieringsrapporter - räkna fram perioder utifrån dagens datum - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.

Name: Kopieringsrapporter - räkna fram perioder utifrån dagens datum fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of Kopieringsrapporter - räkna fram perioder utifrån dagens datum.php

  1. <?php
  2.  
  3. $Dates = PrintCountStartStop();
  4.  
  5. foreach($Dates as $Dt)
  6. {
  7.     echo "<p>" . date("Y-m-d H:i:s",$Dt) . "</p>";
  8. }
  9.  
  10. function PrintCountStartStop()
  11. {   
  12.     $CurrPeriodEnd = mktime(11,8,59,3,1,2022);
  13.         //$CurrPeriodEnd = time(); // Alltså just nu!
  14.         $CurrYear = (int) date("Y",$CurrPeriodEnd);
  15.         $CurrMonth = (int) date("m",$CurrPeriodEnd);
  16.         $CurrPeriodStartYear = $CurrMonth < 3 ? $CurrYear - 1 : $CurrYear;
  17.         $InvoicePeriodStartYear = $CurrPeriodStartYear - 1;
  18.         $CurrPeriodStartDate = mktime(0,0,0,3,1,$CurrPeriodStartYear);
  19.         $InvoicePeriodEndDate = $CurrPeriodStartDate - 1; // En sekund tidigare än startdatum
  20.                                                                                                           // för löpande period
  21.         $InvoicePeriodStartDate = mktime(0,0,0,3,1,$InvoicePeriodStartYear);
  22.  
  23.  
  24.         $RetVal = array();
  25.         $RetVal['invoicestart']= $InvoicePeriodStartDate;
  26.         //fablog('invoicestart',date("Y-m-d H:i:s"));
  27.         $RetVal['invoicestop'] = $InvoicePeriodEndDate;
  28.         $RetVal['currperiodstart'] = $CurrPeriodStartDate;
  29.         $RetVal['currperiodend'] = $CurrPeriodEnd;
  30.  
  31.         return $RetVal;       
  32.        
  33. }
  34.  
File Description
  • Kopieringsrapporter - räkna fram perioder utifrån dagens datum
  • PHP Code
  • 12 Sep-2022
  • 1012 Bytes
You can Share it: