Text Formatting - Query From MySQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post by Paddy »

Ah, ok. :) Alrighty then. You can use getdate

http://au2.php.net/manual/en/function.getdate.php

This splits the current timestamp up into an array. You can then just grab the pieces you want and then turn them into a string that MySQL will qualify as a date. Let me know if you need more of a help.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you are just looking for the current date you can simply use MySQL's NOW() function:

Code: Select all

$query = "INSERT INTO message_table (title, designation, message, date_created) VALUES ('$title', '$designation', '$message', NOW())";
Mac
Post Reply