Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php的datepicker中从日期中提取日期和月份(大写)?_Php - Fatal编程技术网

如何在php的datepicker中从日期中提取日期和月份(大写)?

如何在php的datepicker中从日期中提取日期和月份(大写)?,php,Php,我想从日期选择器中的日期中提取日期和月份,以数字形式显示日期,以字母形式显示月份(如对于03它应该显示为Mar) 示例:2016年9月3日 我想显示从数据库中选取的日期中的日期(9)和月份(作为三月而不是03)。有人可以建议如何执行此操作吗?date()函数格式化本地日期和时间,并返回格式化的日期字符串 j=没有前导零(1到31)的月份中的某一天 M=一个月的简短文本表示法(三个字母) 只需使用这个: $date = "03/09/2016"; echo date("j M", strt

我想从日期选择器中的日期中提取
日期
月份
,以数字形式显示日期,以字母形式显示月份(如对于
03
它应该显示为
Mar

示例:2016年9月3日

我想显示从数据库中选取的日期中的日期(9)和月份(作为三月而不是03)。有人可以建议如何执行此操作吗?

date()函数格式化本地日期和时间,并返回格式化的日期字符串

  • j=没有前导零(1到31)的月份中的某一天
  • M=一个月的简短文本表示法(三个字母)
只需使用这个:

$date = "03/09/2016"; 

echo date("j M", strtotime($date));
结果

3月9日


假设可以使用DateTime库解析日期:

$date = new DateTime('2000-01-01 10:34:44');
echo $date->format("Y-M-d");
这将输出
2000-Jan-01

这里概述了所有不同的日期输出类型:

如果您查看
php
date
手册,就很容易了:

注意:-如果您不想要
year
,您可以从
echo date(“jm Y”,strotime($date))中简单地删除
Y

<?php
$date = '03/09/2016'; // your actual date
echo date("j M Y", strtotime($date)); // conversion into string format
j =  Day of the month without leading zeros (1 to 31)
M = A short textual representation of a month, three letters(Jan through Dec)