[X] Choose Font Here

Y2K38 in PHP

PHP မွာ ဒီ Code ေလးကို copy ကူးျပီး run ၾကည့္ရင္ ဘာေပၚမယ္ ထင္လဲ?

<?php  
$date = '2040-02-01';
$format = 'l d F Y H:i'; 
$mydate1 = strtotime($date); 
echo '<p>', date($format, $mydate1), '</p>';  
?>


Wednesday 1 February 2040 00:00 လို႔ေပၚမယ္ ထင္ပါသလား? ေရးရမွာ ပ်င္းရင္ေတာ့ ဒီမွာ run ၾကည့္လို႕ ရပါတယ္။ Result က ဒီလိုတဲ့ဗ်ာ။ Wednesday 31 December 1969 17:00

သူကို Y2K38 လို႔ေခၚျပီး 2038 ကေန စျပီး 1969/70 ကို ႏွစ္ေပါင္း ၇၀ ေလာက္နီးပါး  ေနာက္ ျပန္ေရာက္သြားတာ ကိုေတြ႔ရမယ္။ တကယ္လို႕မ်ား ကိုယ့္ application ထဲ membership plan ေတြကို ေရာင္းတဲ့ application ဆိုရင္ေတာ့ အဲဒီေန႕မွာ expire ျဖစ္မျဖစ္ ကိုဒီအတိုင္း စစ္ရင္မွား ပါေတာ့မယ္။

Date Time ကို ျပဖို႔ 32 Bits ကိုသုံးထားတဲ့ PHP နဲ႔ တျခားေသာ programming languages ေတြအားလုံးမွာ ဒီ bug ကိုေတြ႔ ရပါမယ္။ 32 bit မွာ Date Time ေတြကို 03:14:07 UTC on 19 January 2038 ေတြအထိပဲ ရွိေနျပီး အဲဒါေက်ာ္တာနဲ႔ left-most bit က negative ျဖစ္သြားျပီး 1969/70 ကိုျပန္ေရာက္ သြားတာ ျဖစ္ပါတယ္။

တကယ္လို႕ 64 bit OS ေပၚမွာ တင္ထားျပီး PHP ကလဲ 64 bit edition ဆိုရင္ေတာ့ ဒီ bug မေပၚႏိုင္ဘူးလို႕ ဆိုပါတယ္။ Coding ထဲက safe ျဖစ္ေအာင္လုပ္ ခ်င္ရင္ေတာ့ ဒီလိုေလး ေျပာင္းျပီး ေရးဖို႔လိုပါတယ္။

<?
$date = '2040-02-01';  
$format = 'l j F Y H:i';  
$mydate2 = new DateTime($date);  
echo '<p>', $mydate2->format($format), '</p>';
?>

Comments (2)
  • nwaylay  - database မွာျမန္မာလိုမေပၚျခင္း

    ညီမ ကို တစ္ခုေလာက္ကူညီေပးပါအုံး
    အေရးျကီးေနလို႔ပါ :D
    edit လုပ္လိုက္ရင္..database ထဲမွာျမန္မာလိုမေပၚလို႔ပါ..Insert တုန္းက ေပၚျပီး..database ေရာ...page မွာပါေပၚပါတယ္...edit က်ေတာ့..page မွာ ေပၚျပီး...database
    မွာမေပါၚေတာ့ဘူး...
    ကူညီေပးပါအုံး

  • admin  - Re:

    Hi Sis,
    Without I seeing any coding, I can say very general answer as to check utf8 at edit coding.

Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

Login Form

Categories Table View

JoomlaWatch Stats 1.2.9 by Matej Koval

Facebook Share

Share on facebook

Accordion FAQ

mod_joomtouch

Version Iphone

Version Iphone by JoomTouch