Пример #1
0
function setToCurrentWeek()
{
    $_SESSION["todaydate"] = date('Ymd');
    $_SESSION["mondate"] = findMonDate($_SESSION["todaydate"]);
    $_POST["currentweek"] = null;
}
Пример #2
0
$servername = "localhost";
$username = $_SESSION['username'];
$password = $_SESSION['password'];
$db_selected = "rbook_db";
$table = "conferenceroom";
$_SESSION["currenttable"] = $table;
// Establish connection to db
$conn = mysqli_connect($servername, $username, $password, $db_selected);
$_SESSION["conn"] = $conn;
// Set up inital date
if (!isset($_SESSION['todaydate'])) {
    $_SESSION["todaydate"] = date('Ymd');
}
// Set up mondate if not already set from next week/previous week functions
if (!isset($_SESSION['mondate'])) {
    $_SESSION['mondate'] = findMonDate($_SESSION['todaydate']);
}
// function to calculate next date
// given a date
// dates are given in format YYYYMMDD
function findNextDate($date)
{
    // check date string is right length
    if (strlen($date) == 8) {
        // first 4 digits -> year
        $year = substr($date, 0, 4);
        $month = substr($date, 4, 2);
        $day = substr($date, 6, 2);
    } else {
        return "Error: string of wrong length";
    }