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
Date and Time functions in php
Moderator: General Moderators
1. Look at MySQL's DATE_FORMATfunction:
2. Use the NOW() MySQL function.
Exp.:
2. Use the NOW() MySQL function.
Exp.:
Code: Select all
INSERT INTO table ( `timestamp_filed` ) VALUES ( NOW() )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.scorphus wrote:1. You can get all information on the [php_man]date[/php_man]() function reference.
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
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.
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.