Welcome Guest, Not a member yet? Register   Sign In
Date to Timestamp?
#1

[eluser]zeedy2k[/eluser]
Anyone able to tell me how I can convert DD/MM/YYYY to a Unix timestamp? I have looked everywhere and cant figure this out.

Thanks
Robert
#2

[eluser]Seppo[/eluser]
You can explode it and mktime
#3

[eluser]mironcho[/eluser]
Hi Robert,
You can achieve this by using mktime (as Seppo said) or strtotime functions:
Code:
$some_date = '22/05/2008';
$parts = explode('/', $some_date);

// using strtotime()
$timestamp = strtotime("{$parts[2]}-{$parts[1]}-{$parts[0]}");

// using mktime()
$timestamp = mktime(0, 0, 0, $parts[1], $parts[0], $parts[2]);

More info about both:
http://php.net/manual/en/function.strtotime.php
http://php.net/manual/en/function.mktime.php
#4

[eluser]zeedy2k[/eluser]
Thank you both for your replies




Theme © iAndrew 2016 - Forum software by © MyBB