christriddle
(christriddle@googlemail.com)
1
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
christriddle
(christriddle@googlemail.com)
2
Don't worry guys, just being an idiot!
Cheers
···
On 12 Oct, 14:39, "christrid...@googlemail.com" <christrid...@googlemail.com> 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
7stud
(7stud --)
3
christriddle@googlemail.com 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
···
--
Posted via http://www.ruby-forum.com/\.