This article mainly introduces the calculation of zodiac signs through dates, which has a certain reference value. Now I share it with everyone. Friends in need can refer to it
Start Month | #Constellation | Ending month | #Time interval | ||
---|---|---|---|---|---|
12 | 22 | Capricorn | 1 | 19 | 12/22 - 1/19 |
1 | 20 | Aquarius | 2 | 18 | 1/ 20 - 2/18 |
2 | 19 | Pisces | 3 | 20 | 2/19 - 3/20 |
21 | Aries | 4 | 20 | 3/22 - 4/20 | |
21 | Taurus | 5 | 20 | 4/22 - 5/20 | |
21 | Gemini | 6 | 21 | 5/22 - 6/21 | |
22 | Cancer | 7 | 22 | 6/22 - 7/22 | |
23 | Leo | 8 | 22 | 7/22 - 8/22 | |
23 | Virgo | 9 | 22 | 8/22 - 9/22 | |
23 | Libra | 10 | 22 | 9/22 - 10/22 | |
23 | SCORPIO | 11 | 21 | 10/22 - 11/21 | |
22 | Sagittarius | 12 | 21 | 11/22 - 12/21 | |
22 | Capricorn | 1 | 19 | 12/22 - 1/ 19 |
x | y | x y = 19 | x | y | x y =23 |
---|---|---|---|---|---|
10 | 9 | 14 | 9 | √ | |
11 | 8 | 15 | 8 | √ | |
12 | 7 | 16 | 7 | √ | |
13 | 6 | 17 | 6 | √ | |
14 | 5 | √ | 18 | 5 | √ |
4 | √ | 19 | 4 | √ | |
3 | √ | 20 | 3 | ||
2 | √ | 21 | 2 | ||
√ | 22 | 1 | ##19 | ||
√ | 23 | 0 | ## 两列中x的交集为 14 -19 Date = [22, 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22] Copy after login date - 14 startMonth = month - [(day < Date[month]) ? 1 : 0] => month - (day - 14 < '865778999988'.charAt(month)) true 自动变为 1; true 自动变为 0; charAt为寻找字符串对应位置的str Copy after login 最终代码 var date = new Date(2017,1,12); //设置日期 function getHoroscope(date) { var c = ['摩羯','水瓶','双鱼','白羊','金牛','双子','巨蟹','狮子','处女','天秤','天蝎','射手','摩羯'] var month = date.getMonth() + 1; var day = date.getDate(); var startMonth = month - (day - 14 < '865778999988'.charAt(month)); return c[startMonth] } getHoroscope(date); //水瓶 Copy after login 以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网! 相关推荐: |
The above is the detailed content of How to calculate horoscope from date. For more information, please follow other related articles on the PHP Chinese website!