Rails 3 Finding day of week

前端 未结 5 1599
旧巷少年郎
旧巷少年郎 2020-12-08 13:13

I\'m trying to make my own calendar because i cant seem to get any help with event calendar so what im trying to do is Display the day of the week ie.. January 1 2011 is a S

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 13:22

    If you're attempting to write your own calendar from scratch and want to write a function to do day lookup, you might want to check out Conway's Doomsday Algorithm, which is an interesting method for determining the day of the week on any given date. Otherwise the standard time class has a wday method which returns a number from 0-6 (0 is Sunday, 1 is Monday, etc).

提交回复
热议问题