Jump to content

date() get veritable


westman

Recommended Posts

There are a few ways, but the one I'd recommend is simply using the DateTime class. You don't need to use three "variables" (BTW, the word is "variable", not "varitable").If you need to do calculations with dates (why else do you need the date parts separately?), there are a lot of helper methods, like diff() for example.If you don't, you can just call format() with the portions you need, e.g.

<?php$date = new DateTime();$y = $date->format('Y');$m = $date->format('m');$d = $date->format('d');?>

Link to comment
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
×
×
  • Create New...