-3

I want to convert the date in above format to the equivalent Unix Timestamp. I searched a lot but couldn't get any solution. Can anyone help me out to resolve this issue? Thanks in Advance.

PHPLover
  • 1
  • 51
  • 158
  • 311

7 Answers7

4

Quick and dirty:

$pieces = explode("/", "11/03/2013");
echo strtotime($pieces[1]."/".$pieces[0]."/".$pieces[2]);
unicorn80
  • 1,107
  • 2
  • 9
  • 15
1

I think you need to use this strtotime($date);

Venkata Krishna
  • 4,287
  • 6
  • 30
  • 53
1

Try this strtotime('11/03/2013');

SHANib
  • 708
  • 2
  • 14
  • 44
1
strtotime('Jun 26,12');

That will sort all of your problems.

Husman
  • 6,819
  • 9
  • 29
  • 47
1

if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed.

Try using this...

strtotime( str_replace( '/', '-', '11/03/2013') ) );

You can find more details here...

Community
  • 1
  • 1
Ashwini Agarwal
  • 4,828
  • 2
  • 42
  • 59
0

If you have a very spezial Format, then with DateTime

DateTime::createFromFormat('11-2013.03', 'd-Y.m')->getTimestamp()

if its a normal Date-Format, then with strtotime()

Yaslaw
  • 51
  • 2
0

PHP >= 5.2

$date = DateTime::createFromFormat('d/m/Y', '11/03/2013');
echo $date->format('U');

PHP >= 5.3

$date = DateTime::createFromFormat('d/m/Y', '11/03/2013');
echo $date->getTimestamp();
bitWorking
  • 12,485
  • 1
  • 32
  • 38