Ask Experts Questions for FREE Help !
Ask
    TechProNow's Avatar
    TechProNow Posts: 29, Reputation: 2
    New Member
     
    #1

    Nov 22, 2009, 01:12 PM
    Need PHP/MySQL help, for opensource
    I am using PHP Point of Sale, and I need a simple function added to the sales form.

    REF: PHP Point Of Sale

    In the file /sales/sale_ui.php

    I need to add a date/time function to post to the MySQL database. And then print or echo so that the information is physically printable for the EU, but also saved in the DB.

    Something for these type of variables:

    $datetimein
    $datetimeout


    I am a nuub. So I am looking for how to add the PHP code, and how to create the MySQL database table.

    Basically the this function will need to log when I customer starts the transaction, and when the customer ends the transaction.
    So there is really going to need to be two fields, and two functions. Start and stop time of the transaction.

    I am just learning PHP, but I understand HTML and CSS very well.

    Please help, Im stuck. Thanks!

    P.S.

    This is something that I found, that seems like it would work. But I can not get it to work for me:

    <?

    $datefromdb = $guest['guest_time'];
    $year = substr($datefromdb,0,4);
    $mon = substr($datefromdb,4,2);
    $day = substr($datefromdb,6,2);
    $hour = substr($datefromdb,8,2);
    $min = substr($datefromdb,10,2);
    $sec = substr($datefromdb,12,2);
    $orgdate = date("l F dS, Y h:i A",mktime($hour,$min,$sec,$mon,$day,$year));
    ?>
    Date: <? Echo $orgdate; ?>
    rpray2007's Avatar
    rpray2007 Posts: 319, Reputation: 23
    Full Member
     
    #2

    Mar 18, 2010, 09:36 AM

    Don't know if you already have the answer for this, but here goes:
    1) Use unix_timestamp (which is the # of seconds since 1/1/1970) and is automatically set to the server time. I'm assuming your db and web server are physically on the same box or at least in the same timezone. The field type is simply an int(11)
    2) you can use the date() function to format the date anyway you want.
    3) When updating the database simply use the mysql function "unix_timestamp()" for updating that field. This will automatically take the current time on the server and push it into the time.
    4) Be very consistent on the server as to what timezone you are using. Displaying is very different than storing time in the DB.

    Hope these pointers are helpful. Respond with more questions if needed.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

MySQL Tutorials [ 2 Answers ]

This website hosts over a dozen MySQL Tutorials: PICKaTUTORIAL.COM -- Free online open source mySQL / SQL (Structured Querry Language) database programming tutorials / articles / guides and more!

MySQL Databases [ 3 Answers ]

I'm cleaning up my website accounts. I use cPanel. I have a list of databases, some of which I'm sure I'm not using... Clearly I've not been smart about naming some of them... How can I verify what the databases are for? Yep, I'm a dummy. Am I making sense?

Databases and mySQL what? [ 1 Answers ]

Hey, I want to make an interactive website and for me to do that I need to understand the world of databases in other words mySQL or SQL don’t really know anything about the subject. Actually I don’t really know why I have to use a database for my interactive website at all… For example I want...

C++ and mysql [ 2 Answers ]

I want a query that can select all names in a table and write it in sequential form in a listbox of a form in C++.the connection is well established and communication between my system and my datbase is working fine. here is the statement I used: requestName = SELECT SystemName FROM System;...


View more questions Search