# Timestamp

**URL:** <https://www.ruby-forum.com/t/timestamp/136914>\
**Category:** Ruby\
**Created:** [May 7, 2008, 11:09am UTC](https://www.ruby-forum.com/t/timestamp/136914 "2008-05-07T11:09:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [May 7, 2008, 11:09am UTC](https://www.ruby-forum.com/t/timestamp/136914/1 "2008-05-07T11:09:02Z")

</div>

i want attaches a timestamps to file for this i doing Time.now\_filename  
but it gives error because time has a space sum it so i need some  
another mechanism using which i generate timestamps and attached to  
timestamps.

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [May 7, 2008, 11:59am UTC](https://www.ruby-forum.com/t/timestamp/136914/2 "2008-05-07T11:59:56Z")

</div>

Dear Sunny,  
-------- Original-Nachricht --------

> Datum: Wed, 7 May 2008 18:09:03 +0900  
> Von: Sunny B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: removed\_email\_address@domain.invalid  
> Betreff: timestamp

> ## i want attaches a timestamps to file for this i doing Time.now\_filename but it gives error because time has a space sum it so i need some another mechanism using which i generate timestamps and attached to timestamps.
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

maybe you attach Time.now.to\_s.gsub(/ /,‘\_’) ?  
There are also methods to extract the day, the hour or the second from a  
Time object:

[www.ruby-doc.org/core/classes/Time.html](http://www.ruby-doc.org/core/classes/Time.html)

Best regards,

Axel
