在希腊语区域设置中设置日期

时间:2016-07-08 10:04:29

标签: php date character

我在数据库中插入了一个日期。但每当我这样做时,我会在日期字段中看到

    1st January, 1970

我尝试使用官方php文档中显示的setLocal()函数

    setlocale(LC_CTYPE, 'greek');

但仍有同样的问题!

这是我的php代码:

<?php 
//Newcastle 3 - 3 Man Utd
include("./init.php");

if(isset($_POST['submit'])){

 $post_game = $_POST['game'];

 $time = strtotime($_POST['date']);
 //13 Δεκ 2016
 //$post_date = date('D, jS', $time) . ' of ' . date('F', $time);
 $post_date = date('jS F, Y',$time);
  setlocale(LC_CTYPE, 'greek');


if($post_game==''){

    echo "<script>alert('Please fill in all fields')</script>";
    exit();
    }
else {

    $insert_game = "insert into last_game (game,date) values ('$post_game','$post_date')";

    $run_posts = mysqli_query($con,$insert_game); 

        echo "<script>alert('Post Has been Published!')</script>";

        echo "<script>window.open('index.php?last_game_details','_self')</script>";

    }

}

  ?> 
  

1 个答案:

答案 0 :(得分:1)

首先尝试添加lc_ctype然后再添加lc_time

include("./init.php");
// add this here
setlocale(LC_CTYPE, 'greek');
setlocale(LC_TIME, 'greek');