Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP date(): minutes without leading zeros

Tags:

date

php

format

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 manually test for and remove leading zeros?

like image 597
Bojangles Avatar asked Jan 09 '11 12:01

Bojangles


2 Answers

Use:

$minutes = intval(date('i')); 
like image 161
AbdullahC Avatar answered Sep 21 '22 09:09

AbdullahC


For times with more information than just minutes:

ltrim() - Strip whitespace (or other characters) from the beginning of a string

ltrim(date('i:s'), 0); 

returns:

8:24 
like image 21
ScottA Avatar answered Sep 18 '22 09:09

ScottA