Page 1 of 1
Date and Time functions in php
Posted: Wed May 19, 2004 11:40 pm
by php_kid
Hi All,
I am new to php.I am learning php now,can anyone give me solution for my following doubts,
1.I have a DateTime field in my table.It stores the currenty date/time to my table.Now i want to display it with yyyy/mm/dd format.
2.I have a timestamp(14) field in my table.What does it mean and how do i insert the current date/time.
Thanks,
php_kid
Posted: Thu May 20, 2004 12:42 am
by jason
1. Look at MySQL's
DATE_FORMATfunction:
2. Use the NOW() MySQL function.
Exp.:
Code: Select all
INSERT INTO table ( `timestamp_filed` ) VALUES ( NOW() )
Posted: Thu May 20, 2004 12:44 am
by scorphus
Hi, welcome to PHPDN Forums.
1. You can get all information on the [php_man]date[/php_man]() function reference.
2. Assuming you're using MySQL, the Documentation covers TIMESTAMP column type on these links:
Scorphus.
Posted: Thu May 20, 2004 12:52 am
by jason
scorphus wrote:1. You can get all information on the [php_man]date[/php_man]() function reference.
Though, it would be easier to do it in SQL. I find that people get lazy, and leave everything to PHP when you can still do so much in SQL. I try to push the data formatting down as far as possible, so that when I get the result from the database, I don't have to deal with formatting it. I just get the result and start working with it.
Posted: Thu May 20, 2004 1:13 am
by scorphus
Hello
Jason,
Very good point. From time to time I see my weakness on MySQL. I always forget to let the work with it, an already compiled, linked, loaded and well written code. Thanks for the advice, and sorry for
postposting your post.
Well, here is a direct link to the
DATE_FORMAT() function reference.
Scorphus.