It is much easier to use the mysql DATE_FORMAT() function to format your dates when retrieving directly from the data base. You do not have to convert to a UNIX time stamp and all that other stuff.
Your select statement should look something like: $date_format_long="%d:%m:%y at %T"; $query="select DATE_FORMAT(date_field, '$date_format_long' ) as fmt_date from your_table"; RTM at http://www.mysql.com Chapter 6 ----- Original Message ----- From: "Torkil Johnsen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, January 29, 2002 7:29 PM Subject: [PHP] Date & time > Hello... > > I have a field in my mysql database containing date&time on the format > YYYY-MM-DD HH:MM:SS (24-hour format) > > Now. I want to output this as follows: DD.MM.YY at HH:MM:SS > Currently I do this by this function: > > function convert_datetime($in){ > $return = substr($in,8,2) . "." . substr($in,5,2) . "." . substr($in,2,2) . > " at " . substr($in,11,8); > return $return; > } > > Is there a better way? Either with mysql or php? > Now. Another problem. Since my webserver is in the states, and I live in > Norway, I get a 7 hour time difference. > > So when I do date("Y-m-d H:i:s") I get a time that is 7 hours wrong. > Any idea as to how I can correct this to be 7 hours later (that is: 12 in > server time is really 19 where I live) in an easy way? > > THanks in advance, > Torkil > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]