logo
down
shadow

I need to insert the date and time of employee stamp in and out into mysql database


I need to insert the date and time of employee stamp in and out into mysql database

By : rolly hernando
Date : November 29 2020, 09:01 AM
I hope this helps . JQuery fullCalendar comes with a function getDate() that returns a Moment for the current date of the calendar.
For not refreshing the page, you need to use AJAX. Try below code
code :
<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
    header("Location: index.php");
}
$res=mysql_query("SELECT users.*, employees.* FROM users  NATURAL JOIN employees WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);

?>
<!DOCTYPE html>
<html lang="en">
 <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../favicon.ico">

    <title>Welcome - <?php echo $userRow['username']; ?></title>
    <!-- Bootstrap core CSS -->
    <link href="../../dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="jumbotron-narrow.css" rel="stylesheet">

    <!-- debug and js -->
    <script src="../assets/js/ie-emulation-modes-warning.js"></script>

    <!-- CSS FOR MY CALENDAR -->
    <link href="../../dist/css/bootstrap-combined.min.css" rel="stylesheet">    
    <link href="//arshaw.com/js/fullcalendar-1.5.3/fullcalendar/fullcalendar.css" rel="stylesheet" />
    <link href="http://arshaw.com/js/fullcalendar-1.5.3/fullcalendar/fullcalendar.print.css" rel="stylesheet" />
    <link href="kalenda.css" rel="stylesheet">  

    <!-- SCRIPTS FOR MY CALENDAR -->
    <script class="cssdesk" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
    <script class="cssdesk" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js" type="text/javascript"></script>
    <script class="cssdesk" src="netd-bostpdn.js" type="text/javascript"></script>
    <script class="cssdesk" src="//arshaw.com/js/fullcalendar-1.5.3/fullcalendar/fullcalendar.min.js" type="text/javascript"></script>


 </head>

 <body>
    <div class="container">
        <div class="header clearfix">
            <nav>
              <ul class="nav nav-pills pull-right">
                <li role="presentation"><a href="logout.php?logout">Log Out</a></li>
              </ul>
            </nav>
            <h2 class="text-muted">Hi, <?php echo $userRow['last_name'];?>&nbsp; | Employee No: <?php echo $userRow['emp_no'];?></h2>
        </div>

        <div class="jumbotron">
            <h2>Please time stamp</h2>
            <div class="container">
                <div id='calendar'></div>
            </div>          
        </div>
            <br>
        <tr>
            <td>
                <center>
                    <p>
                        <form>
                            <input type="button" class="btn btn-lg btn-success" value="Clock In" id="my-button">
                        </form>                             
                    </p>    
                </center>
            </td>
        </tr>

        <!-- Javascript -->
        <script>
            $(function() {
              var date = new Date();
              var d = date.getDate();
              var m = date.getMonth();
              var y = date.getFullYear();

              $('#calendar').fullCalendar({
                header: {
                  left: 'prev,next today',
                  center: 'title',
                  right: 'month,agendaWeek,agendaDay'
                },
                editable: true
              });
            });

            // add button click code here
            $('#my-button').click(function() {
                var moment = $('#calendar').fullCalendar('getDate');
                var dateObj = new Date(moment) /* Or empty, for today */
                dateIntNTZ = dateObj.getTime() - dateObj.getTimezoneOffset() * 60 * 1000;
                dateObjNTZ = new Date(dateIntNTZ);
                var nd = dateObjNTZ.toISOString().slice(0, 19);

                 $.ajax({ 
                    url: 'clockin.php',
                    data: { inDate: nd.replace('T', ' ')},
                    type: 'post',
                    success: function(data) {
                            alert(data);  
                    },
                    error: function(data) {
                        alert("Error."); 
                    }
                });
            });
        </script>
    </div>
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
 </body>
</html>
    session_start();

    /* connect to DB */
    include_once 'dbconnect.php';

    if(isset($_POST['inDate']))
    {
        $indate = mysql_real_escape_string($_POST['inDate']);

        $clock_id = NULL;
        $clock_in = $indate;
        $timestamp_in = $indate;
        $user_id = $_SESSION['user'];
        $res2 = mysql_query("INSER INTO emp_log (`clock_id`, `clock_in`, `timestamp_in`, `user_id`) 
        VALUES($clock_id, '$clock-in', '$timestamp-in', '$user_id')");

        if($res2)
            echo "User in time entry successfully made.";
        else
            echo "Error inserting entry data: ".mysql_error();
    }
    else
        echo "No date received.";
<form>
    <input type="button" class="btn btn-lg btn-success" value="Clock In" id="my-button">
</form>
var dateObj = new Date(moment) /* Or empty, for today */
dateIntNTZ = dateObj.getTime() - dateObj.getTimezoneOffset() * 60 * 1000;
dateObjNTZ = new Date(dateIntNTZ);
var nd = dateObjNTZ.toISOString().slice(0, 19);
$('#my-button').click(function() {
                var moment = $('#calendar').fullCalendar('getDate');
                var dateObj = new Date(moment) /* Or empty, for today */
                dateIntNTZ = dateObj.getTime() - dateObj.getTimezoneOffset() * 60 * 1000;
                dateObjNTZ = new Date(dateIntNTZ);
                var nd = dateObjNTZ.toISOString().slice(0, 19);

                 $.ajax({ 
                    url: 'clickin.php',
                    data: { inDate: nd.replace('T', ' ')},
                    type: 'post',
                    success: function(data) {
                            alert(data);  
                    },
                    error: function(data) {
                        alert("Error."); 
                    }
                });
            })
<?php
session_start();

/* connect to DB */
include_once 'dbconnect.php';


    $indate = mysql_real_escape_string($_POST['inDate']);
    $intime = date('H:i:s');

    $clock_id = NULL;
    $clock_in = $indate." ".$intime;
    $timestamp_in = $indate." ".$intime;
    $user_id = $_SESSION['user'];
    $res2 = mysql_query("INSERT INTO emp_log (`clock_id`, `clock-in`, `timestamp-in`, `user_id`) VALUES ($clock_id, '$clock-in', '$timestamp-in', '$user_id')");

    if($res2)
        echo "User in time entry successfully made.";
    else
        echo "Error inserting entry data";
?>


Share : facebook icon twitter icon
insert date and time stamp, vbs

insert date and time stamp, vbs


By : Kunal Vora
Date : March 29 2020, 07:55 AM
Any of those help I'd like to insert the time and date of when the script was executed. So far I just have the username of the person who executed the script.... , You probably want the Now statement:
code :
NewTextFile.WriteLine(Now)
How do add date and time stamp to an INSERT via PHP with mySQL?

How do add date and time stamp to an INSERT via PHP with mySQL?


By : mav3r1ck
Date : March 29 2020, 07:55 AM
Any of those help You got the "add_time" column set up in your database? Is it of DATETIME format?
In that case you may just modify your query like this:
code :
$order = "INSERT INTO cartons_added (type, part_no, add_type, add_qty, 
  add_ref, add_by, add_notes, add_time)

  VALUES
  ('$_POST[type]', 
  '$_POST[part_no]', 
  '$_POST[add_type]', 
  '$_POST[add_qty]', 
  '$_POST[add_ref]', 
  '$_POST[add_by]', 
  '$_POST[add_notes]',
   NOW())";
Can I select record in MYSQL: Sorted according to the date/time created, even if table dont have date/time stamp in it?

Can I select record in MYSQL: Sorted according to the date/time created, even if table dont have date/time stamp in it?


By : vu nguyen
Date : March 29 2020, 07:55 AM
it fixes the issue As other commenters have pointed out, the short answer is no. MySQL doesn't allow you to sort by the time at which a record was created unless you have explicitly stored that value in the database. Here's a possible way out for the future:
code :
ALTER TABLE users ADD COLUMN created_at DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00';
ALTER TABLE users ADD INDEX created_at (created_at);
MySQL - How to insert the current date as Unix time stamp?

MySQL - How to insert the current date as Unix time stamp?


By : Archana
Date : March 29 2020, 07:55 AM
will be helpful for those in need MySQL has a function with the surprising name unix_timestamp:
code :
INSERT INTO `products`
(`name`, `date`)
VALUES ('some name', UNIX_TIMESTAMP())
when inserting date and time in datetime column in mysql database it will insert date but time is 00-00-00

when inserting date and time in datetime column in mysql database it will insert date but time is 00-00-00


By : Alex C
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , See the javadoc of java.sql.Date:
Related Posts Related Posts :
  • CRM 2013 Limit the date field
  • fancybox - changing close button color
  • Ember-notify giving error can't read property "Service" of undefined
  • Passport-init.js authentication is not working in nodejs
  • Branch.io Cordova API - init() fails on Android Device
  • appending HTML codes to an elements using js
  • Css animation to extend button text on hover
  • I want to restrict HTML input autocomplete to 3 letter minimum
  • tinyMCE editor not updating on the fly
  • typescript kendo-ui call method from string
  • HttpCompileException was unhandled by user code (when i am adding c# code in script)
  • Send form data as array of objects to controller in asp.net mvc
  • Javascript, multi file modules and Require.Js
  • how to render a complete new template and leave the application template in ember
  • Hover unrelated divs
  • Permute string until it matches some input?
  • How to fire JQuery change event when input value changed programmatically?
  • AJAX: POST data to a different url
  • checkbox column in jquery datatable
  • Document.evaluate for documents without namespaceURI crashes Microsoft Edge
  • Bootstrap Menu with "More" option Responsive issue
  • Standard inputs not being added to Angularjs Form $Scope
  • Express promise throw error
  • onclick and get in jquery
  • How to get the country code from Google Places API
  • Passing parameters url in Select2
  • Is there any frame work for Marklogic to write javascript code?
  • How to implement a boostrap template over bootstrap-sass gem
  • Why fixed div comes out when horizontally scrolled?
  • How to limit scope of a function in javascript/ jquery
  • Overlapping legend d3.js
  • Apply transition to div
  • Javascript game help - counting with dice
  • How to hide a div from angular controller
  • Can Promise load multi urls in order?
  • How enable Hover event for bootstrap menus?
  • D3 scale.invert() isn't returning date for x
  • Parsing object to array using underscore js or lodash
  • ES6 with React and Browserify
  • AngularJS Factory return type undefined
  • javascript follow html input fields
  • how to declare a double array in javascript for this particular UI
  • Jquery : find length of mixed list
  • Returning the array before the function is complete & Angular JS
  • Javascript set value of class & hidden input in nested divs
  • Register custom filters with vue.js
  • Add class to input parent
  • Angular controller not talking to view
  • Trouble creating "if then" Javascript statement to change background color of page
  • Socket.IO - Middleware and scoping: how should I access global IO object from external middleware?
  • add class when input is valid in angularjs
  • Positioning multiple div elements
  • Checkbox clicking works, deselecting checkbox not working Javascript
  • Adding ajax jQuery File upload
  • Creating a dynamic array within a dynamic array in JQuery
  • Multiple File Upload actions for a single File Input PHP/JS
  • Want to move an added element to a different part of the DOM
  • Why can't I get Angularjs to work?
  • Minimizing browser window in Firefox & Chrome adds white space to right of page
  • Making css auto slider
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co