-
☆ A M B ☆
- 24,524 Posts
You’d need to break the string to get the date portion
$whole_string = explode(' ',$v_LastUp)
//then break up the first part of the string
$date_strings = explode('/',$whole_string[0]);
//then rebuild the date
$new_date = $date_string[1].'/'.$date_string[0].'/'.$date_string[2];
//then rebuild the whole string:
$v_LastUp = $new_date.' '.$whole_string[1];
Thanks to your help the date is now displayed like this:
09/03/2006 06:45:
Do you have any idea on how can I add a+7 hours difference to the total, getting rid also of the final :, so the date/hour could be like this:
09/03/2006 13:45
Thank you so much!
-
☆ A M B ☆
- 24,524 Posts
I have the funny feeling that there are php functions to deal with all of this...I’ll poke around in the php documentation and see what I can find.
-
☆ A M B ☆
- 24,524 Posts
Not yet, but there’s a lot of mysql and php documentation to dig through.
I did find some interesting material here, especially in the comments:
http://il2.php.net/manual/en/function.strtotime.php
In fact, it looks like you can convert the date/time string you get using strtotime(’string’), then set your locale, then use strftime on the timestamp that produces to get the date/time string you want. There are also functions for dealing with gmt, and in php 5 functions for dealing with timezones. There is a lot of information on handling date and time there, and the comments are also well worth reading.
Look at the PHP functions for:
date_default_timezone_get
date_default_timezone_set
Use the latter to set it to the user’s preferred time zone, and then the rest of your code can work unmodified
-
☆ A M B ☆
- 24,524 Posts
Those two functions are new to PHP 5 only.
-
☆ A M B ☆
- 24,524 Posts
or, which is even more hackish, since you know where the feed is coming from, add (or subtract, I can never remember which way it goes) the appropriate value from the original once you convert it from the string to a timestamp, then convert it back to your localized string.
This original date/time value is coming from an RSS feed in the US, which is what causes it to need to be converted in the first place.