1

My intention is to print date like this,
04.10.2015

I have tried,

d=`date '+%d%m%y'` 

But the problem what was happening, it was printing those dates which are two digits (10 to 31). But 1 to 9 date was not printing like 01..02..09 For the single date, the out was coming like this,

4.10.2015 

I think its digit problem. What format should I have to use to print single date in double digit?

1
  • 3
    Your example and command use a completely different format! Your command even includes the time (hours and minutes) where the desired output format does not. So it's not at all clear what you're looking for. Could you please edit your question so that they are at least consistent? In any case, even if I try to guess what you mean, I cannot reproduce your problem. Both the %d and %m specifiers do use loading zeros. Commented Jun 14, 2015 at 11:23

1 Answer 1

5

The command date '+%d.%m.%Y' creates this output: 14.06.2015 (for June 14, 2015).

To assign it to a variable d, use: d=$(date '+%d.%m.%Y').

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.