Use DateTime.parse() to solve this error.
Strftime deals with date objects. You may be trying this with String Value.
Use DateTime.parse() to solve this error.
Strftime deals with date objects. You may be trying this with String Value.
The following code converts the
“time” to new “timezone value”.
Paste the following code in the application.rb or wherever you like
def convert_zone(to_zone)
#notify the current timezone
original_zone = ENV[”TZ”]
#finds UTC time
utc_time = dup.gmtime
#change the zone into the requested zone(parameter
value)
ENV[”TZ”] = to_zone
#convert the UTC time to local time in the changed
zone
to_zone_time = utc_time.localtime
#Now change the zone back to the original zone
ENV[”TZ”] = original_zone
return to_zone_time
end
This function takes the “timezone”(to which you want to convert) as a
parameter and takes control of the rest.
(Eg.)
t = Time.now
# => Sun Sep 09 01:46:40 UTC 2001
t.convert_zone(”Asia/Calcutta”) …
I came across this error when dealing with
Date attribute.
Rails active record throws this error when you try to assign the
“datetime” value to a date attribute.
Changing the db field accordingly fixes this
error.
Export
mysqldump -u username -p password database_name >
FILE.sql
Import
mysqldump -u username -p password database_name <
FILE.sql
Add new tag
ads
bike riding
bug fixes
funs
games
god
installations
Java
javascripts
jokes
lessons
Linux
love
Mac OS
morals
Most Expected
MySQL
Networking
outings
programming
ruby
Ruby on Rails
Scriptures
songs
tips
Trips
Videos
windows Amazed at…. (3)
C,FastCGI (2)
Found it useful (2)
Fun-and-morals (83)
installations (12)
Java (4)
Javascript (3)
Lessons I have learnt (16)
Misc (1)
Most Expected (1)
MySQL (6)
Networking (1)
Photos (1)
Rails - Mac Leopard (9)
Rails deployment–FCGI (1)
Rails deployment–SCGI (1)
Ruby on Rails (65)
Scriptures (12)
Trips (1)
Unix (2)
Videos (29)
Weird Errors (25)
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.