DateTime confusion

Hello!
Wondered if anyone could help…
I’m trying to parse a datetime

date = DateTime.parse(“200701011900”)

Which gives me a datetime. When i print it, it gives:
2007-01-01T19:00:00+00:00=> nil

but when I try:

print date.year

it gives me an unknown method error… any ideas what I’m doing
wrong?

Cheers!
Chris

[email protected] wrote:

Hello!
Wondered if anyone could help…
I’m trying to parse a datetime

date = DateTime.parse(“200701011900”)

Which gives me a datetime. When i print it, it gives:
2007-01-01T19:00:00+00:00=> nil

but when I try:

print date.year

it gives me an unknown method error… any ideas what I’m doing
wrong?

Cheers!
Chris

It works fine for me, although I wouldn’t name the variable ‘date’ since
it is the same name as the file you are including.

require ‘date’

date = DateTime.parse(“200701011900”)
puts date.year

–output:–
2007

On 12 Oct, 14:39, “[email protected]
[email protected] wrote:

print date.year

it gives me an unknown method error… any ideas what I’m doing
wrong?

Cheers!
Chris

Don’t worry guys, just being an idiot!
Cheers