Skip to content

Instantly share code, notes, and snippets.

@vjandrea
Last active December 29, 2016 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vjandrea/5162655 to your computer and use it in GitHub Desktop.
Save vjandrea/5162655 to your computer and use it in GitHub Desktop.
Workdays calendar with Italian localization, used as blueprint for my reports.
<?php
/**
* This script generates a simple list of days formatted as "Dayofweek day(numeric) Month"
* I use this calendar as blueprint for my reports.
* 4th revision with better formatting and some refactoring
*/
define("TOTAL_DAYS", 150);
setlocale(LC_ALL, 'it_IT', 'it', 'IT', 'ita', 'italian');
date_default_timezone_set('Europe/Rome');
$date = new DateTime();
$last = clone $date;
?><html>
<head>
<title><?php
echo $date->format('d/m/Y');
?> to <?php
echo $last->add(new DateInterval('P' . TOTAL_DAYS . 'D'))->format('d/m/Y');
?></title>
<style>
body {
font-size: 11pt;
}
.date {
font-family: "Calibri", sans-serif;
font-weight: bold;
}
</style>
</head>
<body><?php
for ($i = 0; $i <= TOTAL_DAYS; $i++) {
if (date('w', $date->getTimestamp()) != 6) { // exclude saturdays
echo '<span class="date">'
. ucwords(strftime("%A", $date->getTimestamp() )
. ' '
. date('d', $date->getTimestamp() )
. ' '
. strftime("%B", $date->getTimestamp() ))
. '</span>';
}
echo "<br />\r\n<br />\r\n<br />\r\n";
$date->add(new DateInterval('P1D'));
}
?></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment