# Why this ruby code is not working

**URL:** <https://www.ruby-forum.com/t/why-this-ruby-code-is-not-working/84415>\
**Category:** Ruby\
**Created:** [February 4, 2007, 4:27am UTC](https://www.ruby-forum.com/t/why-this-ruby-code-is-not-working/84415 "2007-02-04T04:27:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [February 4, 2007, 4:27am UTC](https://www.ruby-forum.com/t/why-this-ruby-code-is-not-working/84415/1 "2007-02-04T04:27:04Z")

</div>

Why the value of temp2 is not consistent with the value of temp.

Loading development environment.

> > ```
> > list = []
> > 
> > ```

=\> []

> > ```
> > (1..10).to_a.each do |i|
> > 
> > ```

?\> start\_time\_temp = i.days.ago.beginning\_of\_day

> > ```
> > puts start_time_temp
> > temp2 = start_time_temp.strftime("%m-%B-%Y")
> > puts temp2
> > end
> > 
> > ```

Fri Feb 02 00:00:00 -0500 2007  
02-February-2007

Thu Feb 01 00:00:00 -0500 2007  
02-February-2007

Wed Jan 31 00:00:00 -0500 2007  
01-January-2007

Tue Jan 30 00:00:00 -0500 2007  
01-January-2007

Mon Jan 29 00:00:00 -0500 2007  
01-January-2007

Sun Jan 28 00:00:00 -0500 2007  
01-January-2007  
Sat Jan 27 00:00:00 -0500 2007  
01-January-2007  
Fri Jan 26 00:00:00 -0500 2007  
01-January-2007  
Thu Jan 25 00:00:00 -0500 2007  
01-January-2007  
Wed Jan 24 00:00:00 -0500 2007  
01-January-2007  
=\> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [February 4, 2007, 4:46am UTC](https://www.ruby-forum.com/t/why-this-ruby-code-is-not-working/84415/2 "2007-02-04T04:46:30Z")

</div>

Never mind. I just need some coffee.

Sorry for the trouble.
