Jump to content
xisto Community
Sign in to follow this  
iGuest

Date and Time in PHP

Recommended Posts

Does anybody here knows how to make the date in my script from 01-10-2004 to January 10, 2004. My script displays the date in this format and I want to make it like the latter but I don't know how. The script uses a database. Just wanna ask if what type should be the date in the db?I know how to make it January 10, 2004. It's like date("m i, Y")Hope somebody'll reply!

Share this post


Link to post
Share on other sites

i remember when i didnt know this - i made this hugely complicated 'if then' script....then found that it was easy enough.Probably best to just stick 'php time' into google - though i might copy it across for you later.There are 2 different formats....UNIXTIME - which is the number of seconds from the epoch (1st of Jan 1970) (if anyone wants to convert this to number of years / weeks / days/ hours /minutes / seconds ...then i made another script to do it...cos i dont know that much about strings, if someone wants to explain that would be cool)Or there is the date format....generally you get the unix format with the now() command, and get the date format with another one.... its all on google, i havnt remembered it - i just copy it from where i have it when i need it or look it up.

Share this post


Link to post
Share on other sites

Hmm... I'm not sure if I understand your problem correctly, but maybe you need this:

$time= ...  // get the date from database$time=strtotime($time); // converts mysql date format ("2004-11-20") into UNIX type time variable (number of sec. since 1/1/1970)$date=date("m i, Y", $time);  // the date() function takes as an optional second parameter an UNIX type time variable

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.