- Mar., 06-11-2007 8:34
- Ruby On Rails
Hoy me he encontrado con un pequeño problema desarrollando un aplicación en rails. Tenia que calcular la diferencia en días entre dos fechas. En la lista “Ruby on Rails en castellano“, me dieron la solución:
1 2 3 4 5 6 | def distance_of_time_in_days(from_time, to_time = 0, include_seconds = false) from_time = from_time.to_time if from_time.respond_to?(:to_time) to_time = to_time.to_time if to_time.respond_to?(:to_time) distance_in_days = (((to_time - from_time).abs)/86400).round return distance_in_days end |
- Nuevos: Thunderbird 2.0.0.9rc1
- Viejos: Optimizar nuestro código PHP
Comentarios:0
Trackback + Pingback: 0
- TrackBack para este mensaje
- http://www.issux.com/2007/11/06/dias-entre-dos-fechas-en-rails/trackback/
- Enlaces a blogs que referencian:
- Días entre dos fechas en rails from ISSUX.com