Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help converting to unix timestamp

Status
Not open for further replies.

blasterstudios

Technical User
Dec 30, 2004
128
US
Hey. I'm using dreamweaver and i found this calendar popup thing that allows me to select a day out of the year and it inserts it into my form.

It puts it into the format "2005-02-01". I store all my dates in mySQL database in the Unix timestamp format. The question is, how do I convert the date in that field to Unix timestamp before it is updated in the table?

This is the part of my code that dreamweaver uses to update the table row:
Code:
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE invoices SET invoicetype=%s, customerid=%s, terms=%s, orderdate=%s, completiondate=%s, status=%s, paidinfull=%s, notes=%s WHERE invoiceid=%s",
                       GetSQLValueString($_POST['invoicetype'], "text"),
                       GetSQLValueString($_POST['customerid'], "int"),
                       GetSQLValueString($_POST['terms'], "text"),
                    -->GetSQLValueString($_POST['orderdate'], "int"),
                       GetSQLValueString($_POST['completiondate'], "int"),<--
                       GetSQLValueString($_POST['status'], "text"),
                       GetSQLValueString($_POST['paidinfull'], "int"),
                       GetSQLValueString($_POST['editnotes'], "text"),
                       GetSQLValueString($_POST['invoiceid'], "int"));

The 2 inside the arrows (--> <--) are the ones i need to convert to timestamp. I'm assuming it involves:
1: attaching a time to the datestamp (12pm Noon will be fine for all of them)
2: convert the variable into timestamp using something like
$orderdate = date("U",$orderdate);
3: putting that value into this update query.

I'm just not sure how to do that.
 
most likely here:

Code:
GetSQLValueString(strtotime( $_POST['orderdate'] ), "int")

But we can't be completely certain because we don't know what that GetSQLValueString function is doing.

*cLFlaVA
----------------------------
[tt]tastes great, less filling.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top