I have a date field in a database storing details (lets say it's a date of birth). I can input the date when adding to the database - I'm using dropdown menus for Day, Month and Year. The script creates a timestamp and stores to the database, no problems.
What I can't do though, is edit the date. How do I convert a timestamp so that it shows in 3 parts on the same dropdown menus?
Hopefully this makes sense!
[SOLVED] Editing Date
Moderator: General Moderators
- luketheduck
- Forum Newbie
- Posts: 18
- Joined: Mon Apr 19, 2004 9:13 am
- Location: Aylesbury, Bucks, UK
- launchcode
- Forum Contributor
- Posts: 401
- Joined: Tue May 11, 2004 7:32 pm
- Location: UK
- Contact:
Rip it apart bit by bit - the least overhead method would be something like:
You could also split the time stamp on the hypen and colons, but there's no need to go creating all those arrays really. The above will work for any MySQL time stamp.
Code: Select all
<?php
$ts = '2004-08-12 13:45:03';
$year = substr($ts, 0, 4);
$month = substr($ts, 5, 2);
$day = substr($ts, 8, 2);
$hour = substr($ts, 11, 2);
$min = substr($ts, 14, 2);
$sec = substr($ts, 17, 2);
echo "$year $month $day $hour $min $sec";
?>- luketheduck
- Forum Newbie
- Posts: 18
- Joined: Mon Apr 19, 2004 9:13 am
- Location: Aylesbury, Bucks, UK