Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
5分で「へぇ〜」がひとつ増える、PHPの”気になる”関数の話
Search
たきゃはし
November 11, 2025
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
5分で「へぇ〜」がひとつ増える、PHPの”気になる”関数の話
たきゃはし
November 11, 2025
More Decks by たきゃはし
See All by たきゃはし
AI時代のWebセキュリティリスク_レビュワーを救いたい.pdf
takahashiyuya
0
400
date()とかtime()の関数よりDateTimeクラス使った方が良さそう的な話
takahashiyuya
0
15
Laravelのヘルパー
takahashiyuya
1
2.7k
PSR が分かってきた
takahashiyuya
0
590
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
The Invisible Side of Design
smashingmag
301
52k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
870
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
310
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
Transcript
̑Ͱʮ͐ʙʯ͕ ͻͱͭ૿͑Δɺ̥̝̥ ͷ"ؾʹͳΔؔ"ͷ ͖ͨΌ͠ @takahashiyuya - PHPΧϯϑΝϨϯεԬ2025
ɹɹಈػɿPHPͷ͕͍ͨ͠ ඪɿ̍͐ʙҎ্ ɹɹɹɹൃදɿΏΔָ͘͠ΜͰ΄͍͠
ɹɹ͖ͨΌ͠ @takahashiyuya • גࣜձࣾϏοτϑΥϨετʢ݄̓ೖࣾʣ • VAddy ςΫχΧϧαϙʔτΤϯδχΞ • ͖ͳԬͷϥʔϝϯʮ໙զΨ খ܊ຊళʯ
͍͖ͳΓຊͷओ օ༷ɺഥखͰ͓ܴ͍͑ͩ͘͞
date_sun_info()
ͬͯΔ͚ͲɺΒͳ͍ɻ ͦΜͳؔʢॾઆ͋Γʣ
͐ʙ͍ͭͰʹ ͬͯΔ ʹͳ͍ͬͯͨͩͭ͘Γ
͜ͷؔΛޠΔલʹ…
🌅date_sunrise() 🌆date_sunset()
date_sunrise() ɾ date_sunset() • ͷग़ɾͷೖΓͷ࣌ࠁ͕औಘͰ͖Δɻ
͜ΕͰΑ͘ͳ͍ʁ
Α͘ͳ͍
ؔఆٛ date_sunrise( int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude
= null, ?float $longitude = null, ?float $zenith = null, ?float $utcOffset = null ): string|int|float|false
ࣈΑ͘ͳ͍ͱ͜Ζ date_sunrise( int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING, ?float $latitude
= null, ?float $longitude = null, ?float $zenith = null, ?float $utcOffset = null ): string|int|float|false
΄ͱΜͲΑ͘ͳ͍
Α͘ͳ͔ͬͨϙΠϯτ • ҾͰΓͷܕ͕มΘΔ • λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ • Ңܦ͕লུͰ͖Δʢʁʣ
ҾͰΓͷܕ͕มΘΔ • ୈೋҾ $returnFormat • औಘ͢Δ࣌ࠁͷϑΥʔϚοτม͑Δ • ΓΛ string |
fl oat | int ͰͦΕͧΕࢦఆͰ͖Δ • ·͔͞ͷୈೋҾ
λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ୈҾ $utcOffset • ෦తʹઃఆͨ͠λΠϜκʔϯͱؔͳ͍ • σϑΥϧτ͕UTCج४(+0) • ͭ·ΓੈքதͰࢦఆඞਢͳୈҾ͕ര
🆕
ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ • $zenith • `ଠཅͷத৺ͱɺٿͷද໘͔Βͷਨઢͷؒʹͳ֯͢Ͱ͢ɻ` • ઐੑ͕ߴ͍ʹؔΘΒͣखೖྗ • ʮαΠτʹΑ͕ͬͯ࣌ؒҧ͏ʯͱ͍͏ࠞཚ͕ੈքதͰى͖ͨ
Ңܦ͕লུͰ͖Δʢʁʣ • Ͳ͔͜ͷͷग़ɾͷೖΓΛΓ͍ͨͷͰʁ • লུ͢ΔͱɺσϑΥϧτͷҢܦͱ͍͏ṖͷͰॲཧ͞ΕΔ • Ṗͷɿ31.7667, 35.2333
❓PHPΫΠζ❓ σϑΥϧτͷҢܦͲ͜ʁ Ṗͷɿ31.7667, 35.2333
None
ਖ਼ղ ΠεϥΤϧ🇮🇱
ͳΜͰ 🇮🇱ʁʁʁ
PHPΛ ։ൃ Zeev͞ΜɹAndi͞Μ ͷ ݩ
·ͨ Zend … Zeev + Andi ͓ೋਓͷ໊લ͕༝དྷͰ͢
༨ஊσϑΥϧτҢܦ
Α͘ͳ͔ͬͨϙΠϯτ • ҾͰΓͷܕ͕มΘΔ • λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ • Ңܦ͕লུͰ͖Δʢʁʣ
ղܾ͍ͨ͠
Ͳ͏ͬͯʁʁ
ͪΖΜؔͰ👍
date_sun_info()
ੜ·ΕมΘͬͨؔఆٛ date_sun_info( int $timestamp, float $latitude, float $longitude ): array
Γ array shape type array(9) { ["sunrise"] => ͷग़ (ఱ֯
= 90°50′) ["sunset"] => ͷೖΓ (ఱ֯ = 90°35′) ["transit"] => ଠཅ͕࠷ߴ͘ͳΔ࣌ࠁʢೆதʣ ["civil_twilight_begin"] => ໌͚ʢࢢຽബ໌ͷ։࢝, ఱ֯ = 96°ʣ ["civil_twilight_end"] => ༦Εʢࢢຽബ໌ͷऴྃ, ఱ֯ = 96°ʣ ["nautical_twilight_begin"] => ߤւബ໌ͷ։࢝ (ఱ֯ = 102°) ["nautical_twilight_end"] => ߤւബ໌ͷऴྃ (ఱ֯ = 102°) ["astronomical_twilight_begin"] => ఱจബ໌ͷ։࢝ (ఱ֯ = 108°) ["astronomical_twilight_end"] => ఱจബ໌ͷऴྃ (ఱ֯ = 108°) }
Α͘ͳ͔ͬͨϙΠϯτ • ҾͰΓͷܕ͕มΘΔ • λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ • Ңܦ͕লུͰ͖Δʢʁʣ
ੜ·ΕมΘͬͨؔఆٛ date_sun_info( int $timestamp, float $latitude, float $longitude ): array
Α͘ͳ͔ͬͨϙΠϯτ • ✔ ҾͰΓͷܕ͕มΘΔ • λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ • Ңܦ͕লུͰ͖Δʢʁʣ
ੜ·ΕมΘͬͨؔఆٛ date_sun_info( int $timestamp, float $latitude, float $longitude ): array
Α͘ͳ͔ͬͨϙΠϯτ • ✔ ҾͰΓͷܕ͕มΘΔ • ✔ λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ •
Ңܦ͕লུͰ͖Δʢʁʣ
Γ array shape type array(9) { ["sunrise"] => ͷग़ (ఱ֯
= 90°50′) ["sunset"] => ͷೖΓ (ఱ֯ = 90°35′) ["transit"] => ଠཅ͕࠷ߴ͘ͳΔ࣌ࠁʢೆதʣ ["civil_twilight_begin"] => ໌͚ʢࢢຽബ໌ͷ։࢝, ఱ֯ = 96°ʣ ["civil_twilight_end"] => ༦Εʢࢢຽബ໌ͷऴྃ, ఱ֯ = 96°ʣ ["nautical_twilight_begin"] => ߤւബ໌ͷ։࢝ (ఱ֯ = 102°) ["nautical_twilight_end"] => ߤւബ໌ͷऴྃ (ఱ֯ = 102°) ["astronomical_twilight_begin"] => ఱจബ໌ͷ։࢝ (ఱ֯ = 108°) ["astronomical_twilight_end"] => ఱจബ໌ͷऴྃ (ఱ֯ = 108°) }
Α͘ͳ͔ͬͨϙΠϯτ • ✔ ҾͰΓͷܕ͕มΘΔ • ✔ λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ✔ ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ
• Ңܦ͕লུͰ͖Δʢʁʣ
ੜ·ΕมΘͬͨؔఆٛ date_sun_info( int $timestamp, float $latitude, float $longitude ): array
Α͘ͳ͔ͬͨϙΠϯτ • ✔ ҾͰΓͷܕ͕มΘΔ • ✔ λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ✔ ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ
• ✔ Ңܦ͕লུͰ͖Δʢʁʣ
✔ Α͘ͳ͔ͬͨϙΠϯτ • ✔ ҾͰΓͷܕ͕มΘΔ • ✔ λΠϜκʔϯ͕ಠཱ͍ͯ͠Δ • ✔
ఱ֯Λखೖྗ͢Δඞཁ͕͋Δ • ✔ Ңܦ͕লུͰ͖Δʢʁʣ
✔ શղܾ
PHP5.1.0ͰϦϦʔε🎉
ΊͰͨ͠ΊͰͨ͠
…
❓PHPΫΠζ❓ ϦϦʔεޙɺdate_sun_info()Λ ऻͬͨग़དྷࣄͱԿʁ
None
Latitude and longitude are backwards in date-sun-info
date_sun_info() ͷ Ңͱܦ͕ٯͰ͢
͑ Ңͱܦ͕ٯʹ ॲཧ͞Ε͍ͯͨ💥
ͦΜͳ͜ͱ͋ΔΜͩͳ͊
date_sun_info() Λ̑લΑΓ ͬͯΔʹͳΕͨͰ͠ΐ͏͔ʁ
ͱΓ͋͑ͣಈ͔ͤΔ ͦͷͨΊͷศརͳ͕ؔ͋Δ ࣗʹͱͬͯɺͦΕ͕PHPΒ͠͞
͋Γ͕ͱ͏ PHPΧϯϑΝϨϯεԬ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ ʮ͐ʙʯͷ͚ͩഥखΡʙʙʙ👏
ࢀরɿhttps://github.com/php/php-src/blob/php-8.4.14/ext/date/php_date.c#L247-L248 🇮🇱 ·͓ͩΔͰʙ