Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting separate month, day and year values into a timestamp

Tags:

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?

like image 685
A Clockwork Orange Avatar asked Jun 01 '11 22:06

A Clockwork Orange


People also ask

How do you convert a date to a number in Python?

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.


1 Answers

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'); ?> 
like image 153
Madhawa Priyashantha Avatar answered Sep 22 '22 18:09

Madhawa Priyashantha