HighDots Forums  

new to MySql PHP - timestamp for date

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss new to MySql PHP - timestamp for date in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Leesa
 
Posts: n/a

Default new to MySql PHP - timestamp for date - 07-03-2004 , 06:07 PM






Hi,
I have tried every combo I can think of to get a hidden form variable to pass
the timestamp into the MySQL table. I know I am getting the timestamp in php
because I print the value to the page during testing. But it uploads into the
MySQL database as 00/00/0000. Here is an example of the timestamp: 1088892113

In DW Server behavior I've tried associating the number with an interger and
date. In MySQL I've used timestamp, date, int.

Don't really care if it shows up in the database as the number or an actual
date and time combo. If I can even get the # into MySQL I should be able to
manipulate it back onto a page as just the date and/or time.

Code section for hidden field in form. I took the ?s out of the php code
below:

<php $time_now = time(); >
<label>
<input type="hidden" name="UserRegDate" id="UserRegDate" value="<= $time_now
Quote:
"
php Print $time_now;

Thanks. Leesa



Reply With Quote
  #2  
Old   
Michael Fesser
 
Posts: n/a

Default Re: new to MySql PHP - timestamp for date - 07-03-2004 , 06:37 PM






.oO(Leesa)

Quote:
I have tried every combo I can think of to get a hidden form variable to pass
the timestamp into the MySQL table.
Why do you put it into a hidden field then? Doesn't make sense for me.
Why not use the MySQL function NOW() or CURDATE() on insert?

Quote:
I know I am getting the timestamp in php
because I print the value to the page during testing. But it uploads into the
MySQL database as 00/00/0000. Here is an example of the timestamp: 1088892113
MySQL doesn't store timestamps by default (you would have to use an INT
field for this), it stores dates/time in ISO-format YYYY-MM-DD HH:MM:SS.

Quote:
In DW Server behavior I've tried associating the number with an interger and
date. In MySQL I've used timestamp, date, int.
Fields of type TIMESTAMP are updated automatically whenever the record
is modified. I think DATE or DATETIME is what you need.

Quote:
Don't really care if it shows up in the database as the number or an actual
date and time combo. If I can even get the # into MySQL I should be able to
manipulate it back onto a page as just the date and/or time.

Code section for hidden field in form. I took the ?s out of the php code
below:

php $time_now = time();
Try

<?php $time_now = date('Y-m-d H:i:s');?>

or

<?php $time_now = strftime('%Y-%m-%d %T', time());?>

HTH
Micha


Reply With Quote
  #3  
Old   
Leesa
 
Posts: n/a

Default Re: new to MySql PHP - timestamp for date - 07-03-2004 , 09:38 PM



Thanks! That's just what I needed. I've been searching the web and found this
article that helped explain it too.
http://www.phpfreaks.com/mysqlmanual/page/manual_Reference.html#DATETIME

Just starting to play with PHP/MySql. Little bit different from ASP.

Appreciate your help. Leesa


Reply With Quote
  #4  
Old   
Joe Makowiec
 
Posts: n/a

Default Re: new to MySql PHP - timestamp for date - 07-04-2004 , 06:53 AM



On 03 Jul 2004 in macromedia.dreamweaver, Leesa wrote:

Quote:
Just starting to play with PHP/MySql. Little bit different from ASP.
You'll find a *lot* of help straight from the source:

http://www.php.net/

The online manual generally has a clear, to the point explanation of what
you're looking for.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php


Reply With Quote
  #5  
Old   
Michael Fesser
 
Posts: n/a

Default Re: new to MySql PHP - timestamp for date - 07-04-2004 , 09:44 AM



.oO(Leesa)

Quote:
Just starting to play with PHP/MySql. Little bit different from ASP.
It's a good idea to have the manuals available as local copies, you
should download them:

http://www.php.net/download-docs.php
http://dev.mysql.com/doc/

Also have a look at the online versions from time to time because of the
user contributed notes.

Quote:
Appreciate your help. Leesa
You're welcome.

Micha


Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.