January 9, 2011

PHP date(): minutes without leading zeros

Question by JamWaffles

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?

Answer by Hippo

Use:

$minutes = intval(date('i'));

Answer by Starx

This also works

$timestamp = time(); //Or Your timestamp
echo (int)date('i',$timestamp);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!