DateTime confusion

C

christriddle

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
 
C

christriddle

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

Don't worry guys, just being an idiot!
Cheers
 
7

7stud --

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top