<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean Behan&#039;s Web Development Portfolio and Blog &#187; datetime</title>
	<atom:link href="http://seanbehan.com/tag/datetime/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Development, Wordpress, Moodle, Ruby on Rails and Design in Burlington, Vermont</description>
	<lastBuildDate>Fri, 30 Jul 2010 17:17:12 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails Helper to Remove Leading Zero in 12 Hour Time Format</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 23:39:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[12 hour time]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[initializers]]></category>
		<category><![CDATA[leading zero]]></category>
		<category><![CDATA[strftime]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=829</guid>
		<description><![CDATA[I can&#8217;t find a strftime() format that will output the hour without the leading zero.  For instance 6:20 will be instead 06:20. This just looks a little sloppy. I created a datetime.rb intializer which will contain custom datetime formats for my application.

# RAILS_ROOT/config/initializers/datetime.rb
Time::DATE_FORMATS[:date] = "%a %b %d, %Y"
Time::DATE_FORMATS[:time] = "%I:%M%p"
# ...

Next I set up [...]


Related posts:<ol><li><a href='http://seanbehan.com/programming/yield-a-block-within-rails-helper-method-with-multiple-content_tags-using-concat/' rel='bookmark' title='Permanent Link: Yield a Block within Rails Helper Method with Multiple Content_tags Using Concat'>Yield a Block within Rails Helper Method with Multiple Content_tags Using Concat</a></li>
<li><a href='http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/' rel='bookmark' title='Permanent Link: Ruby Strftime Day Without the Leading Zero'>Ruby Strftime Day Without the Leading Zero</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t find a strftime() format that will output the hour without the leading zero.  For instance 6:20 will be instead 06:20. This just looks a little sloppy. I created a datetime.rb intializer which will contain custom datetime formats for my application.</p>
<pre>
# RAILS_ROOT/config/initializers/datetime.rb
Time::DATE_FORMATS[:date] = "%a %b %d, %Y"
Time::DATE_FORMATS[:time] = "%I:%M%p"
# ...
</pre>
<p>Next I set up a helper function which will string together the :date and :time formats and remove the leading zero in the hour with the .gsub method on the string.</p>
<pre>
  # RAILS_ROOT/app/helpers/application_helper.rb
  def fulltime(created_at)
    created_at.to_s(:date)+" "+created_at.to_s(:time).gsub(/^0/,'').downcase
  end
</pre>
<p>In a view I&#8217;ll just pass the timestamp to the fulltime function</p>
<pre>
fulltime(@post.created_at)
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/programming/yield-a-block-within-rails-helper-method-with-multiple-content_tags-using-concat/' rel='bookmark' title='Permanent Link: Yield a Block within Rails Helper Method with Multiple Content_tags Using Concat'>Yield a Block within Rails Helper Method with Multiple Content_tags Using Concat</a></li>
<li><a href='http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/' rel='bookmark' title='Permanent Link: Ruby Strftime Day Without the Leading Zero'>Ruby Strftime Day Without the Leading Zero</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate MySQL Datetime Type Using PHP Date() Function</title>
		<link>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/</link>
		<comments>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 18:22:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[strftime]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=779</guid>
		<description><![CDATA[If you want to insert a datetime that matches the default mysql datetime type format use this 

date('Y-m-d H:i:s');



Related posts:Managing Timestamps in MySQL with a Trigger
Problem slash Bug in Rails with attr_accessor and Datetime Select Fields
Custom Date Formats for Your Rails Application



Related posts:<ol><li><a href='http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/' rel='bookmark' title='Permanent Link: Managing Timestamps in MySQL with a Trigger'>Managing Timestamps in MySQL with a Trigger</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you want to insert a datetime that matches the default mysql datetime type format use this </p>
<pre>
date('Y-m-d H:i:s');
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/' rel='bookmark' title='Permanent Link: Managing Timestamps in MySQL with a Trigger'>Managing Timestamps in MySQL with a Trigger</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date and Time Helpers in Rails</title>
		<link>http://seanbehan.com/ruby-on-rails/date-and-time-helpers-in-rails/</link>
		<comments>http://seanbehan.com/ruby-on-rails/date-and-time-helpers-in-rails/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 18:16:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[time ago in words]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=545</guid>
		<description><![CDATA[Just for reference http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001695

This post was created about  ago



Related posts:Custom Date Formats for Your Rails Application
Email Obfuscation and Extraction from Text with Rails
Generate MySQL Datetime Type Using PHP Date() Function



Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/email-obfuscation-and-extraction-from-text-with-rails/' rel='bookmark' title='Permanent Link: Email Obfuscation and Extraction from Text with Rails'>Email Obfuscation and Extraction from Text with Rails</a></li>
<li><a href='http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/' rel='bookmark' title='Permanent Link: Generate MySQL Datetime Type Using PHP Date() Function'>Generate MySQL Datetime Type Using PHP Date() Function</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just for reference http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M001695</p>
<pre>
This post was created about <%= time_ago_in_words @post.created_at %> ago
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/email-obfuscation-and-extraction-from-text-with-rails/' rel='bookmark' title='Permanent Link: Email Obfuscation and Extraction from Text with Rails'>Email Obfuscation and Extraction from Text with Rails</a></li>
<li><a href='http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/' rel='bookmark' title='Permanent Link: Generate MySQL Datetime Type Using PHP Date() Function'>Generate MySQL Datetime Type Using PHP Date() Function</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/date-and-time-helpers-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</title>
		<link>http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/</link>
		<comments>http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 19:22:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[attr_accessor]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[data type]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[validations]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=492</guid>
		<description><![CDATA[Looks like there is a problem with using the attr_accessor method with datetime form fields  http://dev.rubyonrails.org/ticket/8983 In Rails 2.3.2, for me at least, the problem seems to be popping up again. While trying to process a date for credit card validation, I keep getting a &#8216;nil.klass&#8217; error. Sure enough, remove the datetime select from [...]


Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/trouble-using-attr_accessor-in-rails-models-and-forms/' rel='bookmark' title='Permanent Link: Trouble Using Attr_Accessor in Rails Models and Forms'>Trouble Using Attr_Accessor in Rails Models and Forms</a></li>
<li><a href='http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/' rel='bookmark' title='Permanent Link: Generate MySQL Datetime Type Using PHP Date() Function'>Generate MySQL Datetime Type Using PHP Date() Function</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/' rel='bookmark' title='Permanent Link: Onchange Event Fired from Select Field in Rails Form'>Onchange Event Fired from Select Field in Rails Form</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Looks like there is a problem with using the attr_accessor method with datetime form fields  http://dev.rubyonrails.org/ticket/8983 In Rails 2.3.2, for me at least, the problem seems to be popping up again. While trying to process a date for credit card validation, I keep getting a &#8216;nil.klass&#8217; error. Sure enough, remove the datetime select from the form and the problem goes away. I need to look into this a little further because I think that this has been resolved. </p>
<p>More information is available here</p>
<p>http://www.ruby-forum.com/topic/130229</p>
<p>and </p>
<p>http://www.google.com/search?q=1+error(s)+on+assignment+of+multiparameter+attributes&#038;ie=utf-8&#038;oe=utf-8&#038;aq=t&#038;rls=org.mozilla:en-US:official&#038;client=firefox-a</p>
<p>The temporary solution is to not use attr_accessor and rather add the field to the database with the correct data type </p>
<pre> t.datetime :your_datetime_attribute_you_were_once_virtualizing</pre>
<p>. Everything then works as normal. Oh well&#8230;   </p>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/trouble-using-attr_accessor-in-rails-models-and-forms/' rel='bookmark' title='Permanent Link: Trouble Using Attr_Accessor in Rails Models and Forms'>Trouble Using Attr_Accessor in Rails Models and Forms</a></li>
<li><a href='http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/' rel='bookmark' title='Permanent Link: Generate MySQL Datetime Type Using PHP Date() Function'>Generate MySQL Datetime Type Using PHP Date() Function</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/' rel='bookmark' title='Permanent Link: Onchange Event Fired from Select Field in Rails Form'>Onchange Event Fired from Select Field in Rails Form</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
