I have a month value (1-12), day value (1-31), and a year value (2010,2011,2012). I also have a hour value and a minute value.
How can I give this to strtotime()
in a way it can convert it to a timestamp?
strftime() object. In this method, we are using strftime() function of datetime class which converts it into the string which can be converted to an integer using the int() function. Returns : It returns the string representation of the date or time object.
why convert string to date when you already know year month and date.
use setDate funtion
<?php $date = new DateTime(); $date->setDate(2001, 2, 3); echo $date->format('Y-m-d'); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With