ERuiz Posted December 25, 2006 Share Posted December 25, 2006 Hello all and Merry Christmas,I have a small problem. I have a variable which outputs a time such as "03:27". And I need this hour value outputted as a decimal time. In this scenario, the desired output would be "3.5".How can this be accomplished?The variable containing the standard time is called $arData[31]Thanks for any help.Regards,Efrain Ruiz Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/ Share on other sites More sharing options...
Orio Posted December 25, 2006 Share Posted December 25, 2006 [code]<?php$time = explode(":",$arData[31]);$in_decimal = $time[0]+round(($time[1]/60),2);echo $in_decimal;?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/#findComment-147588 Share on other sites More sharing options...
ERuiz Posted December 25, 2006 Author Share Posted December 25, 2006 Orio, AMAZING!!!! THANKS SO MUCH! ;D ;D ;D Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/#findComment-147591 Share on other sites More sharing options...
ERuiz Posted December 25, 2006 Author Share Posted December 25, 2006 Another thing, Orio...If I have a variable that stores a coordinate exactly in this format:N18 23.5725 W66 23.8565And I need to change this coordinate into decimal degrees such as this:18.3928, -66.3976In the example above, in order to get the .xxxx value, we need to divide xx.xxxx by 60 (ej: 23.5725/60 = .3928). Also, I need to have a comma separating the 2 values.How can this be accomplished? Keep in mind that the letter W or S, needs to be converted to a - (negative sign)The name of the variable is $positionThanks for any help.Regards,Efrain Ruiz Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/#findComment-147593 Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 your 3.5 is rounded? is it suppose to be 3.45 if to exact? Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/#findComment-147594 Share on other sites More sharing options...
ERuiz Posted December 25, 2006 Author Share Posted December 25, 2006 [quote author=ted_chou12 link=topic=119891.msg491380#msg491380 date=1167074353]your 3.5 is rounded? is it suppose to be 3.45 if to exact?[/quote]As a matter of fact, 3.45 is more precise and is perfectly fine. ;-) I prefer it not to be rounded. Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/#findComment-147595 Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 okay. Link to comment https://forums.phpfreaks.com/topic/31831-solved-convert-standard-time-to-decimal-time/#findComment-147598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.