0

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

Anonymous
  • 911
  • 1
  • 8
  • 22

2 Answers2

1

php mktime()

//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,211
  • 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,516
  • 12
  • 25