Ask Experts Questions for FREE Help !
Ask

Need PHP/MySQL help, for opensource

Asked Nov 22, 2009, 12:12 PM — 1 Answer
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, I'm 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, why h:i A",mktime($hour,$min,$sec,$mon,$day,$year));
?>
Date: <? Echo $orgdate; ?>

1 Answer
rpray2007's Avatar
rpray2007 Posts: 320, Reputation: 110
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.
Helpful

Not your question? Ask your question View similar questions

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Add your answer here.

Remove Text Formatting

Undo
Redo
 
Decrease Size
Increase Size
Bold
Italic
Underline
Align Left
Align Center
Align Right
Ordered List
Unordered List
Decrease Indent
Increase Indent
Insert Email Link
Wrap [QUOTE] tags around selected text
Wrap [CODE] tags around selected text
Wrap [HTML] tags around selected text
Wrap [PHP] tags around selected text
Wrap [YOUTUBE] tags around selected text
Notification Type:



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

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 PHP questions Search