D
D
Diamond2016-04-07 09:14:35
PHP
Diamond, 2016-04-07 09:14:35

How to take only the time from a DateTime object?

When executing a query, a datetime field returns an object of the datetime type with the following properties: date, timezone_type, timezone.
How to get only time? I tried to work with it as an ordinary object:
$row['STARTTIME']->{'date'}
But nothing happened, I also tried to work with it as with a regular array.
Also wanted to do this in sql query:

SELECT CAST(STARTTIME AS TIME) AS STRT FROM tableName

Ps ms sql srv 2008

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2016-04-07
@res2001

select time(STARTTIME) as STRT from tableName

T
ThunderCat, 2016-04-07
@ThunderCat

datepart ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question