PHP date(): minutes without leading zeros

后端 未结 15 1502
粉色の甜心
粉色の甜心 2020-12-13 23:17

I\'d like to know if there is a formatting letter for PHP\'s date() that allows me to print minutes without leading zeros, or whether I have to manuall

相关标签:
15条回答
  • 2020-12-14 00:06
    $current_date = Date("n-j-Y");
    echo $current_date;
    
    // Result m-d-yy
    
    9-10-2012
    
    0 讨论(0)
  • 2020-12-14 00:06

    My Suggestion is Read this beautiful documentation it have all details of php date functions

    Link of Documentation

    And as per your question you can use i - Minutes with leading zeros (00 to 59) Which return you minutes with leading zero(0).

    And Also introducing [Intval()][2] function returns the integer value of a variable. You can not use the intval() function on an object

    0 讨论(0)
  • 2020-12-14 00:09

    use PHP's absolute value function:

    abs( '09' ); // result = 9

    abs( date( 'i' ) ); // result = minutes without leading zero

    0 讨论(0)
提交回复
热议问题