[SOLVED]date and time question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

[SOLVED]date and time question

Post by Calimero »

I need php to give me date or even time (current),

I tried TIME(), but got something very strange :roll: as output.

So, please code to get current date and if possible time.

Thanks Ahead!
Last edited by Calimero on Fri Jun 25, 2004 5:42 am, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

http://php.net/time returns a unix timestamp, you can then pass this unix timestamp into http://php.net/date
(date on it's own without a time passed in uses the current time)
See http://php.net/date for the display/format options
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

THis will echo out the current time in this format

06-23-2004 at 3:57 pm

Code: Select all

echo date('m-d-Y \a\t h:i a' ,time());
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

if u want the time for a specific timezone, i found this bit most easy to configure to your wantings =]

$time = date('g:i:A', strtotime("-0 hours"));
Post Reply