Chef recipe date declaration error

Hi,

i need to declare date as a file name in the default.rb. But the date field is not accepted by chef. please suggest any alternate way for this.

default.rb content

Cookbook Name:: apply_patch_all

Recipe:: default

log = “/var/log/apt-update”
now = “#{date +”%m_%d_%Y"}"
before="/var/log/apt-update/#{now}.before.txt"
after="/var/log/apt-update/#{now}.after.txt"

directory “#{log}” do
owner “deploy01”
group “deploy01”
mode “0775”
action :create
end

execute “pkg_info_before” do
command “dpkg-query -W | tee #{before}”
end

execute “apt-get-update” do
command “apt-get update”
end

execute “apt-get-upgrade” do
command “apt-get upgrade -y”
end

execute “pkg_info_after” do
command “dpkg-query -W | tee #{after}”
end

execute “pkg_difference” do
command “diff #{before} #{after} | tee /var/log/apt-update/difference.txt”
end
~

I am getting this below error
[2016-04-12T17:36:02+05:30] ERROR: undefined method `+@’ for “%m_%d_%Y”:String
[2016-04-12T17:36:02+05:30] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Is there any other way to declare date as file name here ???

Please help me out.

i’ve found the solution for this. you’ve to use
now = Time.now.strftime “%H-%M-%S_%d-%m-%Y”
That’s it.