Newb.. PHP Timestamp

Hey I’m new to both this forum and PHP, so please be patient with me.

I am currently using a PHP script for comments box on my page which i found. When the user submits comments it returns the date of the server (USA) I want to know how to change the script to Europe time.

[php]
function formatDate($val)
{
list($date, $time) = explode(" “, $val);
list($year, $month, $day) = explode(”-", $date);
list($hour, $minute, $second) = explode (":", $time);
return date(“l, j.m.y @ H:ia”, mktime($hour, $minute, $second, $month, $day, $year));
} [/php]

Im just not sure where or how to implement [php]date_default_timezone_set(‘Europe/London’);[/php]

Any help would be appreciated.

Lee

This should do what you want it to do?
[php]

<?php function comment_date() { date_default_timezone_set('Europe/London'); return $post_date = date('Y-m-d H:i:s'); } $myDate = comment_date(); echo $myDate = date('F j, Y g:i A', strtotime( $myDate )); [/php]

Though I didn’t format it the way you want it and the first part is for eventually putting it in a database?

Anyways, I think you can figure that out by going to php.net Manual.

Here’s the way you want it :wink:

[php]<?php
function comment_date()
{
date_default_timezone_set(‘Europe/London’);
return $post_date = date(“l, j.m.y @ H:ia”);

}

echo $myDate = comment_date();[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service