Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ruby On Rails Jalali Date (Shamsi Date)

DZone's Guide to

Ruby On Rails Jalali Date (Shamsi Date)

·
Free Resource
This is Jalali-Gregorian (Shamsi-Gregorian) date converter and also Jalali Date tag creator. Also it extends rails FormBuilder.

You can easily have select Jalai Date tags in your ror applications and convert the date easily by following codes:


Time.now  #=> Sat Nov 07 16:18:16 +0330 2009
jalali_date = JalaliDate.to_jalali(Time.now)
jalali_date.year  #=> 1388
gregorian_date = jalali_date.to_gregorian #=> Sat Nov 07 00:00:00 +0330 2009 


It also extend Rails Form Helper with jalali date select tag:

<% form_for(@post) do |f| %>
   <%= f.jalali_date :created_at, :prefix=>'start_date' %>
<% end %> 

You can get the code from Jalali Convertor
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}