<?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; strftime</title>
	<atom:link href="http://seanbehan.com/tag/strftime/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>Ruby Strftime Day Without the Leading Zero</title>
		<link>http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/</link>
		<comments>http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 00:08:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[%e]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[strftime]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=798</guid>
		<description><![CDATA[
%e # rather than %d
Time.now.strftime("%e")



Related posts:Ruby strftime() method arguments
Rails Helper to Remove Leading Zero in 12 Hour Time Format



Related posts:<ol><li><a href='http://seanbehan.com/programming/ruby-strftime-method-arguments/' rel='bookmark' title='Permanent Link: Ruby strftime() method arguments'>Ruby strftime() method arguments</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/' rel='bookmark' title='Permanent Link: Rails Helper to Remove Leading Zero in 12 Hour Time Format'>Rails Helper to Remove Leading Zero in 12 Hour Time Format</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<pre>
%e # rather than %d
Time.now.strftime("%e")
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/programming/ruby-strftime-method-arguments/' rel='bookmark' title='Permanent Link: Ruby strftime() method arguments'>Ruby strftime() method arguments</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/' rel='bookmark' title='Permanent Link: Rails Helper to Remove Leading Zero in 12 Hour Time Format'>Rails Helper to Remove Leading Zero in 12 Hour Time Format</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/feed/</wfw:commentRss>
		<slash:comments>0</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>
	</channel>
</rss>
