I need to know how to convert 07:00pm of the current date in microtime. Sorry if this is a silly question but I cannot find the answer anywhere
Asked
Active
Viewed 289 times
0
-
nothing in the manual? http://php.net/manual/en/function.microtime.php saw a few. – Funk Forty Niner Oct 21 '15 at 20:50
-
@Fred-ii- where? I cannot see the solution to my problem there – Anonymous Oct 21 '15 at 20:53
-
this `$micro_date = microtime(); $date_array = explode(" ",$micro_date); $date = date("Y-m-d H:i:s",$date_array[1]); echo "Date: $date:" . $date_array[0];` seemed promising. – Funk Forty Niner Oct 21 '15 at 20:53
-
@Fred-ii- Sorry but I don't see how that is related. I need something like strtotime(date("Y-m-d 19:00:00")); but this is not working. – Anonymous Oct 21 '15 at 20:55
-
I said it "seemed promising" ;-) of course you'd have to add a few ingredients to the soup. See the answers you've been given. – Funk Forty Niner Oct 21 '15 at 20:57
-
check out this Q&A http://stackoverflow.com/questions/10289160/php-get-microtime-from-date-string – Funk Forty Niner Oct 21 '15 at 21:01
-
Not a silly question, but not very well explained. Try again, maybe with an example of what you are actually trying to do – RiggsFolly Oct 21 '15 at 21:06
2 Answers
1
//set timezone to default
date_default_timezone_set('UTC');
//this will give you the timestamp of today, 7:00:00 pm (which is 19 o' clock in 24hour system
$time = mktime(19,0,0);
you then can format the timestamp to whatever kind of format you need.

Tanuel Mategi
- 1,253
- 6
- 13
0
Have you tried making a DateTime
object, then formatting it into unix time?
$dt = new DateTime('7:00pm');
echo $dt->format('U');
There are obviously more efficient ways to do it if you're not dealing with a string to begin with.

calcinai
- 2,567
- 14
- 25