is it possible to use a vaiable within the date() insted of using y-m-d. i want to use $day-$month-$year
gchurch
0
Junior Poster in Training
Recommended Answers
Jump to PostI don't think so. Just from using it enough, I believe it takes the format from the date(), so a variable would do nothing. If you want to print a date with your variables, I would suggest doing something such as this:
echo ''.$month.'/'.$date.'/'.$year.'';
Jump to PostIf the value of $day-$month-$year evaluates to a string like 'd-m-Y' or any other combination of php date formats then yes you could.
<?php $day = 'd'; $month = 'm'; $year = 'Y'; $format = "$day-$month-$year"; // d-m-Y echo date($format); // 31-08-2010
If the value of $day-$month-$year …
All 5 Replies
jkaye
0
Designer/Developer
mschroeder
251
Bestower of Knowledge
Team Colleague
gchurch
0
Junior Poster in Training
gchurch
0
Junior Poster in Training
gchurch
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.