How to add hour to date

I am trying to get the date with a variable year, month and day but an specific hour.

Let me explain myself. I have a variable called $date using the next format

date=$(date +%Y%m%d)

Which gives me 20130814 (for today). Just as I want for that variable

But I need another variable, let's call it $date1 who will have something like $date but an specific hour. I mean, taking the example above, 2013081405. I need to add that 05 to $date every single day, that means that for tomorrow I will have 2013081505 and so on

Upvotes: 1

Views: 1569

Answers (2)

twalberg
twalberg

Reputation: 62369

The bash syntax for that would be:

date1="$(date +%Y%m%d)05"

Upvotes: 5

Leo T Abraham
Leo T Abraham

Reputation: 2437

Why can't you try

$date1 = $date."05";

Upvotes: 1

Related Questions