Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'config.php';
- error_reporting(E_ALL & ~E_NOTICE);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>insert date</title>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <meta charset="UTF-8">
- <!-- Include CSS File Here-->
- <link href="style3.css" rel="stylesheet">
- </head>
- <body>
- <form method = 'post'>
- <h3>Date:
- <input type = 'date' class = 'date' maxlength = '17' placeholder = '11-04-2019 17:20' name = 'date[]' required>
- </h3>
- <?php
- <!-- Date example: 03-04-2019 14:48 -->
- $date = date("d-m-Y H:i", strtotime("+2 hours"));
- //date('Y-m-d H:i:s', strtotime($date));
- //date('d-m-Y H:i', strtotime($date));
- $plus2hrs = date("d-m-Y H:i", strtotime("+2 hours"));
- //d - Day of the month, 2 digits with leading zeros
- //m - Numeric representation of a month, with leading zeros
- //Y - A full numeric representation of a year, 4 digits
- //h - 12-hour format of an hour with leading zeros
- //i - Minutes with leading zeros
- //a - Lowercase Ante meridiem and Post meridiem
- //MySQL Database Connect
- include 'config.php';
- // Check if date form is submitted successfully
- if(isset($_POST["submit"]))
- {
- // Check if any option is selected
- if(isset($_POST["date"]))
- {
- // Retrieving each selected option
- foreach ($_POST['date'] as $date)
- //print "<br/>on the <b/>$date</b/>";
- print "<br/>on the <b/>$date</b/>";
- }
- else
- print "<br/>Select an option first !!";
- }
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- // Now post entries also into DB
- if(isset($_POST["submit"])) {
- {
- // Retrieving each selected option
- foreach ($_POST['date'] as $date) {
- $sql = "INSERT INTO `$dbname`.`$table` (`date`) VALUES ('$date')";
- }
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement