Oh! I had misunderstood the problem. I thought he needed the time to be converted to the client’s timezone. If all you need to do is change to the local server time, that’s a no brainer then.
No. I don’t need to change it to the server’s time - All I need is to take this string:
03/13/2006 04:45:00
And convert it to European format, adjusting the time for local time, so to show it as follows:
13/3/2006 alle ore 11:45
Following sottwell’s suggestion, I tested the snippet with these lines:
$timestamp = strtotime($v_LastUp);
$data = date(’j/n/Y G:i’, $timestamp);
$output.= "<font size=\"1\"><b> ".$data." </b></font>";
And I succeeded in correctly formatting the date in the European format:
13/3/2006 04:45
Now, the only problem is the addition of a +7 hours difference to the time, so to take into account the local time zone. And possibly adding "alle ore" text between date and time.
I read the strtotime page of PHP manual, but I didnt’ find how to add a time difference. Can you please point me to the right direction?
Thanks a million!
-
☆ A M B ☆
- 24,524 Posts
You’ll need to add 7 hours to the timestamp you generate; I’m not sure of the math involved, it’s in seconds, so you would need to add 60x60x7 to the timestamp (I think...).
$timestamp = strtotime($v_LastUp);
$timestamp += (60x60x7);
$data = strftime('%x alle ore %X', $timestamp);
%x is the locale-preferred date part, %X is the locale-preferred time part. As far as adding the string, you can add whatever you like in strftime’s first argument in between the format specifiers. The %whatever are just placeholders for formatted data taken from the timestamp.
-
☆ A M B ☆
- 24,524 Posts
I enjoyed this conversation very much, Iearned a lot about handling data/time in php! Good stuff to know.