Format Float to n decimal places

I need to format a float to “n”decimal places. was trying to BigDecimal, but the return value is not correct… public static float Redondear(float pNumero, int pCantidadDecimales) { // the function is call with the values Redondear(625.3f, 2) BigDecimal value = new BigDecimal(pNumero); value = value.setScale(pCantidadDecimales, RoundingMode.HALF_EVEN); // here the value is correct (625.30) return … Read more

Convert one date format into another in PHP

Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date(‘y-m-d-h-i-s’); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date(‘Y-m-d H:i:s’, $middle); // returns 1970-01-01 00:00:00 But I’d of course like it to return a current date rather than the crack ‘o … Read more