[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

formating...

say I have string that contains GMT-05:00 (EST) but I only want it to display -5, etc...
or instead of "GMT+01:00" use +1, etc... How could I about formatting something like that... any ideas? :)
0
lamerhooDJV
Asked:
lamerhooDJV
  • 2
  • 2
1 Solution
 
snoyes_jwCommented:
Perhaps not the best way, but try this:
echo substr($theString, 3, 3) + 0;
0
 
BatalfCommented:
One example:

<?

$value = "GMT+05:00";
$value = intval(substr($value,3,3));
if($value>=0)$value="+$value";

?>

0
 
lamerhooDJVAuthor Commented:
the first one displays just 5, is there anyway for it to display say + or - based on the GMT zone, of course...

the second displayed nothing :(  not sure if I did something wrong or not...

thanks for your guys' input :)
0
 
BatalfCommented:
Forgot to echo the $value in my post

<?

$value = "GMT+05:00";
$value = intval(substr($value,3,3));
if($value>=0)$value="+$value";

echo $value; // NEW LINE
?>
0
 
lamerhooDJVAuthor Commented:
I should have just read the code, DUH!! lol thanks man!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now