Log in

View Full Version : Need PHP/MySQL help, for opensource


TechProNow
Nov 22, 2009, 01:12 PM
I am using PHP Point of Sale, and I need a simple function added to the sales form.

REF: PHP Point Of Sale (http://www.phppointofsale.com/downloads.php)

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
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.