2
0

calendar_data.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. //calendar
  3. //定義2019年衛塞節日期,返回julian_day
  4. //$vesakha_2019_date=date_create("2019-05-18");
  5. //返回unix時間戳
  6. //$vesakha_2019_unix=jdtounix($vesakha_2019_jd);
  7. //$now_date=date_create();
  8. //获取当緯度
  9. $atitude=$_GET['atitude'];
  10. //获取当經度
  11. $longitude=$_GET['longitude'];
  12. //$sun_AT=$_GET['sun_AT'];
  13. $date=$_GET['date'];
  14. //$selected_date=$_GET['selected_date'];
  15. //$year=$_GET['year'];
  16. //$month=$_GET['month'];
  17. //$day=$_GET['day'];
  18. $year=date_format(date_create($date),"Y");
  19. $month=date_format(date_create($date),"M");
  20. if($date==null){
  21. $date=strtotime("now");
  22. }
  23. else{
  24. $date=strtotime($date);
  25. }
  26. $date_1=$date+24*3600;
  27. //太陽赤緯
  28. //$selected_date_string="{$year}-{$month}-{$day}";
  29. $diff_time=$date-strtotime("{$year}-01-1");//date_timestamp_get(date_create("{$year}-01-1"));
  30. $N=$diff_time/3600/24;
  31. $year_day=366-ceil($year%4/4);
  32. $b=2*pi()*($N-1)/$year_day;
  33. /**
  34. * [$sun_angle 太陽赤緯,弧度]
  35. * @var [type]
  36. */
  37. $sun_angle=0.006918-0.399912*cos($b)+0.070257*sin($b)-0.006758*cos($b*2)+0.000907*sin($b*2)-0.002697*cos($b*3)+0.00148*sin($b*3);
  38. /**
  39. * [$sun_info description]
  40. * @var [type]
  41. */
  42. $sun_info=date_sun_info($date,$atitude,$longitude);
  43. $sun_info_1=date_sun_info($date_1,$atitude,$longitude);
  44. //太陽高度,弧度
  45. $sun_h_degree=pi()/2-abs(($atitude/180*pi()-$sun_angle));
  46. //蒙氣差(horizontal refraction)修正值
  47. $hori_ref=37/60/180*2*pi();
  48. $hori_ref_real=asin(sin($hori_ref)/sin($sun_h_degree));
  49. //$delta_t=$hori_ref_real*(12*3600/pi());
  50. $delta_t_A=$sun_info['civil_twilight_begin']-$sun_info['astronomical_twilight_begin']+$sun_info['nautical_twilight_begin']-$sun_info['sunrise'];
  51. $delta_t=$delta_t_A;
  52. /**
  53. * [$Unix_dawn description]
  54. * @var [type]
  55. */
  56. $Unix_dawn=($sun_info['civil_twilight_begin']-$delta_t)*1000;
  57. $Unix_dawn_1=($sun_info_1['civil_twilight_begin']-$delta_t)*1000;
  58. $Unix_noon=($sun_info['sunrise']+$sun_info['sunset'])/2*1000;
  59. $Unix_noon_1=($sun_info_1['sunrise']+$sun_info_1['sunset'])/2*1000;
  60. echo "{$Unix_dawn}-{$Unix_noon}-{$Unix_dawn_1}-{$Unix_noon_1}-{$sun_h_degree}-{$delta_t}";
  61. //http://127.0.0.1/app/calendar_data.php?atitude=7.738562&longitude=80.519675&date=2020-05-11&year=2020&month=05&day=11
  62. ?>