# Strftime and 10th of a second?

**URL:** <https://www.ruby-forum.com/t/strftime-and-10th-of-a-second/147620>\
**Category:** Rails\
**Created:** [September 3, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/strftime-and-10th-of-a-second/147620 "2008-09-03T17:54:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Birgit\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c77e96/32.png) [@Birgit\_A](https://www.ruby-forum.com/u/Birgit_A)\
**Post date:** [September 3, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/strftime-and-10th-of-a-second/147620/1 "2008-09-03T17:54:51Z")

</div>

Hi all,

I’m using JRuby on Rails 2.x

One of the requirements of my project is to create a recordings filename  
that includes date and time. This is what I’ve got so far.

now = Time.new  
@record\_filename = “”  
@record\_filename += now.strftime(“%Y-%m-%d-%H-%M-%S”)  
@record\_filename += “.wav”

Because some of these files can be create at the same time, I need to  
include a unit that is smaller than seconds, like a 10th of a seconds.

I searched, but it seems that this not possible in strftime().  
Is that correct? If so, any idea how to solve this?  
Counting is not an option.

Thanks, Birgit

–  
– Birgit A., removed\_email\_address@domain.invalid,  
– Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK  
– Company no: 1769350  
– Registered Office:  
– 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.  
– tel.: +44 (0)161 237 0660  
– \<URL: [http://www.westhawk.co.uk](http://www.westhawk.co.uk)\>

---

<div class="post-metadata">

**Author:** ![Birgit\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c77e96/32.png) [@Birgit\_A](https://www.ruby-forum.com/u/Birgit_A)\
**Post date:** [September 3, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/strftime-and-10th-of-a-second/147620/2 "2008-09-03T18:00:43Z")

</div>

On 3 Sep 2008, at 17:53, Birgit A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> @record\_filename = “”  
> @record\_filename += now.strftime(“%Y-%m-%d-%H-%M-%S”)  
> @record\_filename += “.wav”
> 
> Because some of these files can be create at the same time, I need to  
> include a unit that is smaller than seconds, like a 10th of a seconds.
> 
> I searched, but it seems that this not possible in strftime().  
> Is that correct? If so, any idea how to solve this?  
> Counting is not an option.

Just do it yourself: x.strftime(…) + x.usec.to\_s or something along  
those lines.

Fred

---

<div class="post-metadata">

**Author:** ![Birgit\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c77e96/32.png) [@Birgit\_A](https://www.ruby-forum.com/u/Birgit_A)\
**Post date:** [September 4, 2008, 11:28am UTC](https://www.ruby-forum.com/t/strftime-and-10th-of-a-second/147620/3 "2008-09-04T11:28:34Z")

</div>

On 03/09/08 16:59, Frederick C. wrote:

> > Counting is not an option.
> > 
> > Thanks, Birgit
> 
> Just do it yourself: x.strftime(…) + x.usec.to\_s or something along  
> those lines.
> 
> Fred

Hi Fred,

Thanks for your help!

Cheers, Birgit
