time & date

Ask about a PHP problem here.
Post Reply
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

time & date

Post by ashwood »

How would i send time to the database like

hours minutes (5:55PM)

and date like

day/month (11/03)

i want them in to seperate varibles ive googled it but alls ive found is them together

date("d/m/y : H:i:s", time());

but i want to send them to the database as ive put and seperate

thanks :)
I would put a signature.. BUT, i don't have the time.
Torniquet
Posts: 52
Joined: Sun Jun 19, 2011 8:10 am
Contact:

Re: time & date

Post by Torniquet »

so you want a single field for the individual parts of the date and time?

to break them up into individual variables, assign each one individually.
$day = date("d", time());
$month = date("m", time());
... etc
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: time & date

Post by ashwood »

Torniquet wrote:so you want a single field for the individual parts of the date and time?

to break them up into individual variables, assign each one individually.
$day = date("d", time());
$month = date("m", time());
... etc

no i want

time as $time = 5:55PM or whatever the current time is but as that format
date as $date = 10/03 (day/Month) or whatever the current date is but as that format
I would put a signature.. BUT, i don't have the time.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: time & date

Post by jacek »

If you store the time as a DATETIME column you can then use the DATE_FORMAT() mysql function to format it how you like when selecting the data.
Image
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: time & date

Post by ashwood »

jacek wrote:If you store the time as a DATETIME column you can then use the DATE_FORMAT() mysql function to format it how you like when selecting the data.
expand on this please? first time ive heard anything about this?
I would put a signature.. BUT, i don't have the time.
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: time & date

Post by Temor »

ashwood wrote:
jacek wrote:If you store the time as a DATETIME column you can then use the DATE_FORMAT() mysql function to format it how you like when selecting the data.
expand on this please? first time ive heard anything about this?
http://www.w3schools.com/sql/func_date_format.asp
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: time & date

Post by jacek »

The link in the above post has all the info :) do you have any specific question ?
Image
Post Reply