Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Inserting date into table, PHP equivalent of ASP's "now"?
Old 04-11-2005, 04:23 PM Inserting date into table, PHP equivalent of ASP's "now"?
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
I'm trying to insert a date/time code into a mysql database via PHP. I'm trying to insert a date/time in to the database if a date is not submitted via the form. (ie. if $_POST["theDate"] == "", then use the current date). Other than using date() and formatting the date using "y" "m" and "d", is there a way to either set a defualt SQL vault as the current date if nothing is entered, or to have PHP make a time stamp of the current date/time and insert that into the field? Thanks.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
 
Register now for full access!
Old 04-11-2005, 04:29 PM
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
well to insert a time stamp just use time() (i think)
timsquash5 is offline
Reply With Quote
View Public Profile
 
Old 04-11-2005, 04:33 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You can use mysql itself - to put the current date in just run a query along the lines of:

PHP Code:

mysql_query
("INSERT into table (name,tstamp) VALUES ( "Fred", NOW() ) "); 
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-11-2005, 04:51 PM
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
time(); does some weird time format (UNIX time?) I tried the "NOW()" but realized I also needed to spit the variable out to the page, so I guess I'm using date("Y". "-" . "m" . "-" . "d"); to do it. Thanks for the input.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to Inserting date into table, PHP equivalent of ASP's "now"?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.95716 seconds with 12 queries