views:

52

answers:

1

Hi guys,

I have a date in the database and I want to export it to DATE_TIME.civil() format like the one shown below (I am doing this to export it to a .ics calendar file)

DTSTART:20100605T083000

DTEND:20100606T083000

I have two fields in the database one called start_date and two fields start_time and end_time.

I want to add the times (start_time and end_time to the start_date) and convert it to the DATE_TIME.civil() format as shown above. I tried doing the following:

my_datestart = obj.start_date + obj.start_time
my_dataend = obj.start_date + obj.end_time

I know it's a supremely wrong syntax, but my objective is to get the date in that format.

Edit: The database type of start_time => time and start_date => datetime. Both in MySQL. I am using a ActiveRecord to access them

Please help me.

+1  A: 

use strftime method of the date

@date=Time.now
@date.strftime("%Y%m%d %H%M%S")  ####GIVES "20100604 193059"
Salil
Sweet! thank you!
Bragboy