1

I'm trying to convert month,day and year to Unix timestamp.

<?php
  day = '30' ;
  $month = 'November' ;
  $year = '2016' ;
  $t = date('H:i');
  $quoteDate = strtotime("$year-$month-$day $t");
?>

This code gives correct year but wrong day and month.

smc
  • 205
  • 2
  • 10

1 Answers1

1

I think you should try this with DateTime instead, which can be massaged to handle that kind of date string

$day = '30' ;
  $month = 'November' ;
  $year = '2016' ;
  $t = date('H:i');
  $quoteDate = DateTime::createFromFormat("Y-F-d H:i", "$year-$month-$day $t");
echo $quoteDate->format('Y-m-d H:i:s');

You can see a demo here https://3v4l.org/adJ5P

Machavity
  • 30,841
  • 27
  • 92
  • 100