converting "Y-m-d" back to Unix before updating re

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blasterstudios
Forum Newbie
Posts: 13
Joined: Thu Dec 23, 2004 10:08 am
Location: Alabaster, AL
Contact:

converting "Y-m-d" back to Unix before updating re

Post by blasterstudios »

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: Select all

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&#1111;'completiondate'], "int"),<--
                       GetSQLValueString($_POST&#1111;'status'], "text"),
                       GetSQLValueString($_POST&#1111;'paidinfull'], "int"),
                       GetSQLValueString($_POST&#1111;'editnotes'], "text"),
                       GetSQLValueString($_POST&#1111;'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.
Last edited by blasterstudios on Tue Jan 25, 2005 11:29 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

UNIX_TIMESTAMP() function within MySQL.
blasterstudios
Forum Newbie
Posts: 13
Joined: Thu Dec 23, 2004 10:08 am
Location: Alabaster, AL
Contact:

Post by blasterstudios »

I'm sorry, but i don't understand what that means.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply