Forum: Ruby calendar event

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sushrut S. (Guest)
on 2009-04-09 17:38
In my application i use such table(table as follows) in which the
Date_time field by default takes (2001-07-21 11:31:00 UTC)such time
format but i want only date, then how i remove the created_time &
updated_time.
Also how to change the format of date i want dd/mm/yyyy


-------------------------------------------------------------------------
creation_id     Modification_id      Delete    Date_time

X               Data                   N     2001-07-21 11:31:00 UTC
-------------------------------------------------------------------------
Robert K. (Guest)
on 2009-04-09 17:52
(Received via mailing list)
On 09.04.2009 15:39, Sushrut S. wrote:
> In my application i use such table(table as follows) in which the
> Date_time field by default takes (2001-07-21 11:31:00 UTC)such time
> format but i want only date, then how i remove the created_time &
> updated_time.

Then you should use class Date.

require 'date'
puts Date.today

> Also how to change the format of date i want dd/mm/yyyy

You should make the distinction between internal and external
representation: internally you use a data type that properly abstracts
"dates".  For output you transform this into a suitable format.

irb(main):008:0> Date.today.strftime "%d/%m/%Y"
=> "09/04/2009"

If you internally need also time then you can use class DateTime and
apply the same formatting:

irb(main):010:0> DateTime.now.strftime "%d/%m/%Y"
=> "09/04/2009"

HTH

Kind regards

  robert
This topic is locked and can not be replied to.