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.
Asked
Active
Viewed 360 times
-3
-
2You couldn't have searched much: `strtotime()` http://php.net/manual/en/function.strtotime.php – mcryan Mar 11 '13 at 11:21
-
Try this strtotime('11/03/2013'); – SHANib Mar 11 '13 at 11:22
-
Do some basic search dude before posting Question : ) - – SHANib Mar 11 '13 at 11:23
-
1Also try searching google and stackoverflow. This question has been asked so many times. – Husman Mar 11 '13 at 11:23
-
This question has been asked already. http://stackoverflow.com/questions/11324195/convert-date-to-unix-timestamp – GBRocks Mar 11 '13 at 11:27
-
Check this out.. http://stackoverflow.com/q/12278943/1288198 – Ashwini Agarwal Mar 11 '13 at 11:37
7 Answers
4
Quick and dirty:
$pieces = explode("/", "11/03/2013");
echo strtotime($pieces[1]."/".$pieces[0]."/".$pieces[2]);

unicorn80
- 1,107
- 2
- 9
- 15
1
Try this strtotime('11/03/2013');

SHANib
- 708
- 2
- 14
- 44
-
Try this.. `date(d/m/Y, strtotime("11/03/2013"));` And see what you get.. – Ashwini Agarwal Mar 11 '13 at 11:31
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