...

View Full Version : date formating question



kwhubby
03-21-2004, 08:45 AM
Hi, I am wondering how I would convert a date from the format of
2004-03-21 00:00:00 into 3/21/04 I am not to great in php so I dont know how to do this in php.

sidney
03-21-2004, 01:46 PM
$string="2004-03-21 00:00";

$date=date("m/d/y",strtotime($string));
echo $date;

kwhubby
03-22-2004, 05:43 AM
Great :thumbsup: thanks :D

mr_ego
03-22-2004, 06:25 AM
For everyone who reads this thread, I would like to stress emphasis on Unix Timestamps.

What is a unix timestamp?
A unix timestamp is a number that calculates the date relative to the epoch (the 1/1/1970, i think, either that or '75). It tells the computer how many seconds since the epoch you are talking about in time.

An Example?



THIS: SELECT Now()
RETURNS: 22-03-2004

THIS: SELECT UNIX_TIMESTAMP()
RETURNS: 1079936537

THIS: SELECT UNIX_TIMESTAMP(Now())
RETURNS: 1079936537


From what we see here, we're selecting the time from SQL (alternatively, you can get the time from the function: time())

The difference is that because the first two are in Unix Timestamp format, you can pass them through the date() function in PHP to show the kind of date that you want.

Despite the name
Despite the name, yes you can use Unix Timestamps on Windows servers.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum