PHPSL Function:  Deg_to_DMS( )

  • Deg_to_DMS ($AngDeg, $ssDecimals=0, $PosSign='', $ReturnMode='d')

    Dependencies: NONE


    This function was designed to turn decimal degree values into DMS strings for things such as tabulating computed angles, such as planetary positions or geographic coordinates into neat columns of degrees, minutes and seconds.

    For example, given the angular string argument, '149.2340195723430531', the equivalent DMS output string = +149° 14' 02.4705", would be returned.

    Several different output formats are possible as is shown by the demo calls below.

    Double-Click to select ALL code

    Double-Click to select ALL code




    EXAMPLE call results:
    
     $AngDeg = '149.2340195723430531';  // = Decimal degrees argument
    
     print Deg_to_DMS($AngDeg, 0);            // =--> 149° 14' 02"
    
    
     print Deg_to_DMS($AngDeg, 5);           // =--> 149° 14' 02.47046"
    
    
     print Deg_to_DMS($AngDeg, 4, '+');       // =--> +149° 14' 02.4705"
    
    
     print Deg_to_DMS($AngDeg, 3, '+', '');   // =--> +149 14 02.470
    
    
     print Deg_to_DMS($AngDeg, 2,  '', '');   // =--> 149 14 02.47
    
    
     print Deg_to_DMS($AngDeg, 16, '+', 'd'); // =--> +149° 14' 02.4704604349911600"
    
     
Jay Tanner - 2024