966p
966p

Reputation: 575

how to delete firstdigit 0 from date and month

Code:

$today_mem = date("d.m");
echo $today_mem; // -> 15.02

I need to transform dates like 15.02 into 15.2, also need to transform for ex. 07.02 into 7.2 and so on every day. So the question is: how to delete firstdigit 0 from date and month. Any short solutions?

Upvotes: 25

Views: 46343

Answers (3)

John Maingi
John Maingi

Reputation: 11

use

$today_mem = date("j")

Upvotes: 1

Jon
Jon

Reputation: 437336

Use j instead of d and n instead of m:

$today_mem = date("j.n"); 

Reference at the PHP doc site.

Upvotes: 32

chrisn
chrisn

Reputation: 2125

You'll want to use:

$today_mem = date("j.n");
echo $today_mem; // -> 15.2

To remove the leading zeros. See more format modifiers at: php.net/date

Upvotes: 60

Related Questions