Convert to Unix Timestamp

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

How can I convert a date into the Unix timestamp?

I don't really mind what format the date is in, something like MMDDYY
would be fine, can someone show me what code I would need to do that


There's plenty of functions out there to convert FROM a Unix timestamp
but I can't find any for the other way round.

Re: Convert to Unix Timestamp

It's OK I worked it out using the mktime function, sorry to bother

Here's the code in case anyone else is as dumb as me ;-)

$aDate = explode("/",$date);

$unixtime = mktime(0, 0, 0, $aDate[1], $aDate[0], $aDate[2]);

(This will take the $date in format DD/MM/YY)

Re: Convert to Unix Timestamp



Re: Convert to Unix Timestamp

jpedrobarbosa wrote:

Quoted text here. Click to load it

Though that behaves unreliably with dd/mm/(yy)yy dates.

Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux, up 9 days, 15:56.]

                       The Great IE8 Meta Tag Debacle

Re: Convert to Unix Timestamp

didnt know that: thanks ;-)

Site Timeline