westman Posted September 30, 2012 Share Posted September 30, 2012 hi am trying to get the day, month and year in 3 different veritablesi have this...date("Y-m-d")and i need Y, m and d in veritables, how do i do this? Link to comment Share on other sites More sharing options...
boen_robot Posted September 30, 2012 Share Posted September 30, 2012 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 More sharing options...
westman Posted September 30, 2012 Author Share Posted September 30, 2012 thank you so much Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now