Board index   FAQ   Search  
Register  Login
Board index php forum :: Database phpMyAdmin

Automatic date & time input????

How to use phpmyadmin.... phpmyadmin related arguments. Even phpMyAdmin issues

Moderators: macek, egami, gesf

Automatic date & time input????

Postby SOLID » Tue Oct 29, 2002 6:30 pm

Hey All,
How do i get the phpMyAdmin to automatically insert a date in a field and the time in another when a DB entry is made????

Please Help

SOLID
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

Postby DoppyNL » Tue Oct 29, 2002 11:55 pm

If you make a field of the type "timestamp" mysql will automaticly set that to "now()" when an insert or update query is run.

This field can hold the date and the time at the same time.

See http://www.mysql.com/doc/en/DATETIME.html for more details on datetime types.

Greetz Daan
DoppyNL
 

thanks DoppyNL

Postby SOLID » Wed Oct 30, 2002 2:31 pm

thanks DoppyNL,
thats cool, i noticed that you can put just the date is there a way of just putting the time too?

Cheers :D
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

Postby Jay » Wed Oct 30, 2002 2:54 pm

DoppyNL wrote:If you make a field of the type "timestamp" mysql will automaticly set that to "now()" when an insert or update query is run.

This field can hold the date and the time at the same time.

I thought he made that quite clear ;)
Jay
 

Sorry

Postby SOLID » Wed Oct 30, 2002 5:26 pm

Sorry Guys. :oops:
i understand that, its just that the tutorial im learning from is using an access DB and they can do an auto insert date and time seperatly?. and ive already set up seperate coloums for date & time. ill try to modify the code to do it with the one timestamp coloum
thanks for you help

:)
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

question

Postby SOLID » Wed Oct 30, 2002 5:29 pm

1 more question? how can i split them up and use them in different places?
im using coldfusion5 :?:
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia

Postby DoppyNL » Wed Oct 30, 2002 11:55 pm

mysql returns a string with the date and time in it.
Convert that to a unix timestamp, you can use this PHP function for that:
Code: Select all
function mysql_to_php_time($mysql_date)
{
   //-- mktime order = hour,min,sec,month,day,year
   return(mktime(substr($mysql_date,11,2),substr($mysql_date,14,2),substr($mysql_date,17,2),substr($mysql_date, 5,2),substr($mysql_date, 8,2),substr($mysql_date, 0,4)));
}

after that you can use the function date or strftime to make the date/time look like you want.

Greetz Daan
DoppyNL
 

Postby SOLID » Thu Oct 31, 2002 3:36 pm

Thanks DoppyNL
ill give that a go
Cheers :D
SOLID
New php-forum User
New php-forum User
 
Posts: 8
Joined: Tue Oct 08, 2002 6:49 pm
Location: Australia


Return to phpMyAdmin

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.