RSS Amplifier

Damian Nicholson · Dec 12, 2010

Ruby Date format gotcha

0
Sign in to vote or save

Damian Nicholson · Damian Nicholson

Developer working on Ruby on Rails code in text editor with HTML and ERB markup visible on MacBook Pro screen

Here’s a little gotcha that I came across when parsing Date strings for insertion into a mysql date field.

puts Date.parse('12/10/2010')
puts Date.parse('12/1/2010')

In Ruby 1.8.7 you’ll get the following output:

2010-12-10
2010-12-01

Though in Ruby 1.9.2 you’ll get this:

2010-10-12
2010-01-12

A little Ruby date format gotcha to look out for, as it took me a little time to hunt this sucker down.

Related posts

TypeScript code editor showing a build app configuration file with Fastify setup and environment variables

Building a blog with Fastify, SQLite, and zero frameworks

Why I built my blog with Fastify, SQLite, and server-rendered templates instead of Next.js and Postgres. The stack, the trade-offs, and why boring tech won.

Tailwind CSS logo with blue wave icon and black text

Tailwind, layoffs, and a familiar open source tension

Tailwind CSS is a huge open source success, but its business model has limits. A look at layoffs, AI, and why adoption does not equal leverage.

1Password on laptop

Using 1Password as Your SSH Agent on macOS

How to configure 1Password to manage SSH keys and prompt you to approve SSH connections on macOS.

Read the original on damiannicholson.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.