# The above solutions share a problem

**URL:** <https://www.ruby-forum.com/t/the-above-solutions-share-a-problem/76736>\
**Category:** Ruby\
**Created:** [December 27, 2005, 5:04am UTC](https://www.ruby-forum.com/t/the-above-solutions-share-a-problem/76736 "2005-12-27T05:04:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 27, 2005, 5:04am UTC](https://www.ruby-forum.com/t/the-above-solutions-share-a-problem/76736/1 "2005-12-27T05:04:02Z")

</div>

Example:

require ‘date’  
require ‘time’  
dt = DateTime.parse(‘2005-12-24T12:00:00Z’) # UTC  
lt = Time.parse(dt.strftime("%c"))  
puts dt.asctime \<\< " " \<\< dt.zone  
puts lt.asctime \<\< " " \<\< lt.zone

Output:

Sat Dec 24 12:00:00 2005 Z  
Sat Dec 24 12:00:00 2005 CET

Timezone data is lost ("%c" does not include it nor do the other  
examples - at least the ones I saw 🙂

A solution that works very similar but with time zone included (%Z) und  
thus gives expected results:

class DateTime  
def to\_time  
Time.parse(strftime("%a %b %d %H:%M:%S %Z %Y"))  
end  
end

regards

eTM
