Convert m-d-Y to unix format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Convert m-d-Y to unix format

Post by GeXus »

Does anyone know how to convert 08-15-2008 (m-d-Y) format into a unix timestamp for querying in php
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Convert m-d-Y to unix format

Post by Jade »

Can't you use the maketime function and just convert it over? I'm pretty sure there's a function that can give you the date in unix format. Check the php manual: http://us.php.net/manual/en/function.date.php

It should be your new best friend!! :D
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Re: Convert m-d-Y to unix format

Post by GeXus »

Everything seems to be formatting a unix timestamp... I want to do the opposite.. take a formatted date and produce a unix timestamp.. can't seem to find it.
baileylo
Forum Newbie
Posts: 13
Joined: Sun Sep 30, 2007 12:48 am

Re: Convert m-d-Y to unix format

Post by baileylo »

time returns unix time stamp, http://www.php.net/time
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Convert m-d-Y to unix format

Post by EverLearning »

Code: Select all

$date = "08-15-2008";
list($month, $day, $year) = explode("-", $date);
$date = mktime(0, 0, 0, $month, $day, $year);
 
Post Reply