从用户元表的元数据中区分日期


differenciate the date from the meta data of user meta table

我通过下面的代码从用户元表中找到了最后一次登录日期。

$current_user = wp_get_current_user();
  $time = get_user_meta($current_user,"last_login", true);
  echo $time;

我得到如下所示的输出。

2012-12-26 10:00:40 

现在我想区分日期,只打印日期2012-12-26。我怎么能打印日期只通过php。有任何在php或在wordpress中只从数据库中的元表中获取日期。

这可能会解决你的问题:

$date = new DateTime('2012-12-26 10:00:40');
echo $date->format('Y-m-d');

try this

 <?php $date=date('Y-m-d',strtotime('2012-12-26 10:00:40')); 
  echo $date
 ?>

<?php $date=date('Y-m-d',strtotime($time)); 
  echo $date
 ?>