calendar event

S

Sushrut Sathe

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
 
R

Robert Klemme

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,175
Messages
2,570,947
Members
47,498
Latest member
yelene6679

Latest Threads

Top