I want to print date separety like only day or year or month. like: just month not the rest of date time in sql
I do print date like below and its same format in my database
datetime CURRENT_TIMESTAMP
2018-10-27 19:09:49
Thanks for any help
I want to print date separety like only day or year or month. like: just month not the rest of date time in sql
I do print date like below and its same format in my database
datetime CURRENT_TIMESTAMP
2018-10-27 19:09:49
Thanks for any help
you can display date,month,year using below code
for year
SELECT EXTRACT(YEAR FROM "2018-11-01 5:11:10");output:2018
for Month
SELECT EXTRACT(MONTH FROM "2017-06-15 5:11:10");output:6
for Day
SELECT EXTRACT(DAY FROM "2017-06-15 5:11:10");Otput:15
You can get the result to the variable and With PHP you should use an explode() function to achieve the result.
To split the given string it's better to separate date from time by 'space' character, and then use again the explode() function on the given date with a 'dash' symbol.
So it may looks like this:
$first_split = explode(' ', your_datetime_variable);
$date = $first_split[0]; //2018-10-27
$time = $first_split[1]; //19:09:49
$second_split = explode('-', $date);
$year = $second_split[0]; //2018
$month = $second_split[1]; //10
$day = $second_split[2]; //27