从MYSQL上的时间戳提取日/月/年 [英] Extract the Day / Month / Year from a Timestamp on MYSQL

查看:1831
本文介绍了从MYSQL上的时间戳提取日/月/年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

  $ date = $ actualite ['date']; 

$ actualite ['date'] 一个TIMESTAMP



我想知道如何从这个时间戳中提取日期,然后是月份,然后是3个变量中的年份。 / p>

感谢您的帮助:)

解决方案

使用 date_parse($ actualite ['date']); ,它将返回一个包含日,月,年和其他项目的数组。



http://www.php.net/manual/en/ function.date-parse.php



示例:

 <?php 
print_r(date_parse(2006-12-12 10:00:00.5));
?>

输出:

 code> Array 

[year] => 2006
[month] => 12
[day] => 12
[ ] => 10
[分] => 0
[second] => 0
[fraction] => 0.5
[warning_count] => 0
[warnings] => Array()
[error_count] => 0
[errors] => Array()
[is_localtime] =>


I have :

$date = $actualite['date'];

$actualite['date'] is a TIMESTAMP

And I was wondering how can I extract from this timestamp the day, then the month, then the year in 3 variables.

Thank you for your help :)

解决方案

Use date_parse($actualite['date']);, which will return an array containing the day, month, year and other items.

http://www.php.net/manual/en/function.date-parse.php

Example:

<?php
print_r(date_parse("2006-12-12 10:00:00.5"));
?>

Output:

Array
(
    [year] => 2006
    [month] => 12
    [day] => 12
    [hour] => 10
    [minute] => 0
    [second] => 0
    [fraction] => 0.5
    [warning_count] => 0
    [warnings] => Array()
    [error_count] => 0
    [errors] => Array()
    [is_localtime] => 
)

这篇关于从MYSQL上的时间戳提取日/月/年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆