![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
date_time_set() function in PHP
The date_time_set() function sets the time. It returns a DateTime object on success. FALSE on failure.
Syntax
date_time_set(obj, hour, minute, second)
Parameters
obj − DateTime object
hour − Hour of the time to set
minute − Minute of the time to set
second − Second of the time to set
Return
The date_time_set() function returns a DateTime object on success. FALSE on failure.
Example
The following is an example −
<?php $dt = date_create("2018-09-05"); date_time_set($dt,8,15); echo date_format($dt,"Y-m-d H:i:s"); ?>
Output
The following is the output −
2018-09-05 08:15:00
Example
Let us see another example −
<?php $dt = date_create("2017-08-08"); date_time_set($dt,13,24); echo date_format($dt,"Y-m-d H:i:s"); ?>
Output
The following is the output −
2017-08-08 13:24:00
Advertisements