1970 öncesi tarihler için strtotime kullanma

2 Cevap php

I have a text column in mysql and it stores a date value in the format yyyy-mm-dd. Now, in my php page, I use this code to parse into a date value.

date("F j, Y", strtotime($row['value']));

Şimdi, ben sadece () sadece 1 Ocak 1970 sonrasında değerlerini ayrıştırma strtotime okudum. Ben bu tarihten önce tarih değerleri çok şey var. Etrafında bir çalışma var mı? Benim veritabanı yapısını değiştirmek istemiyorum.

2 Cevap

Ben çaylak değilim, ve patlayabilir vs strtotime kullanımına ilişkin bazı benzer sorunları olmamdı. Ben bu konuya karşılaştım ve büyük ölçüde Mark Baker (teşekkürler!) tarafından tarih limiti değişikliği yorum tarafından yardım edildi. Yani sadece konsepti ile oynamak için bu kodu yazdım. Belki de kendim gibi diğer noobs yardımcı olacaktır.

Just change the date on the top PHP line and see what happens to the dates below - very interesting. Thanks again!

<?php $dob = "1890-11-11"; ?>
<html>
<head>
<style>

.inputdiv {
    width:200px;
    margin:100px auto 10px auto;
    background-color:#CCC2FC;
    text-align:center;
    border:1px solid transparent;}

.spacer{
    width:199px;
    margin:20px auto 20px auto;}    

</style>
</head>
<body>

<div class="inputdiv">
  <div class="spacer"><?php echo "Raw dob: ".$dob ?></div>
  <div class="spacer"><?php echo "Strtotime dob: ".date("m-d-Y", strtotime($dob)) ?></div>
  <div class="spacer"><?php list ($y, $m, $d) = explode('-', $dob);
                       $dob = sprintf("%02d-%02d-%04d", $m, $d, $y);
                       echo "Explode dob: ".$dob ?></div>
</div>
</body>
</html>