Automatic date & time input????

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

Moderators: macek, egami, gesf

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

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

DoppyNL

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

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

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

Jay

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 ;)

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

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
Contact:

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 :?:

DoppyNL

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

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

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

Thanks DoppyNL
ill give that a go
Cheers :D


Return to “phpMyAdmin”

Who is online

Users browsing this forum: No registered users and 0 guests