Search
 
SCRIPT & CODE EXAMPLE
 

PHP

create weekly calendar in php

<?php
$dt = new DateTime;
if (isset($_GET['year']) && isset($_GET['week'])) {
    $dt->setISODate($_GET['year'], $_GET['week']);
} else {
    $dt->setISODate($dt->format('o'), $dt->format('W'));
}
$year = $dt->format('o');
$week = $dt->format('W');
?>

<a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week-1).'&year='.$year; ?>">Pre Week</a> <!--Previous week-->
<a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week+1).'&year='.$year; ?>">Next Week</a> <!--Next week-->

<table>
    <tr>
        <td>Employee</td>
<?php
do {
    echo "<td>" . $dt->format('l') . "<br>" . $dt->format('d M Y') . "</td>
";
    $dt->modify('+1 day');
} while ($week == $dt->format('W'));
?>
    </tr>
</table>
Comment

PREVIOUS NEXT
Code Example
Php :: explode return empty array 
Php :: execute function php 
Php :: load session in codeigniter 
Php :: php variable as javascript function parameter in echo 
Php :: laravel s3 download file 
Php :: yii2 gridview action change urls 
Php :: Getting the closest string match using php 
Php :: PHP trim — Strip whitespace (or other characters) from the beginning and end of a string 
Php :: php array serialize 
Php :: Laravel API Endpoint "401 Unauthorized" on Server But Works Fine On Localhost 
Php :: how-to-generate-an-xlsx-using-php 
Php :: php pdo example 
Php :: validate either one field is required in laravel 
Php :: laravel copy image with new name 
Php :: php preg_quote 
Php :: last insert id mysqli 
Php :: php, Africa timezones 
Php :: laravel blade if else condition 
Php :: php aes 
Php :: laravel-enum 
Php :: laravel collection last 
Php :: php session array 
Php :: how to determine if file is empty in php 
Php :: laravel resource api 
Php :: php max int 
Php :: the post function wordpress 
Php :: How to install or setup sanctum for laravel api authentication 
Php :: laravel filter array 
Php :: WordPress Plugin Definition 
Php :: specify php version composer 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =