•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 455,962 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,578 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 1092 | Replies: 7 | Solved
![]() |
•
•
Join Date: Dec 2006
Location: United States
Posts: 613
Reputation:
Rep Power: 3
Solved Threads: 15
You need to first convert the date to a php format. So we use the strtotime() function.
<?php
$date = "2007-11-13"; (or from DB)
$date = strtotime($date);
$aday = date("l",$date);
//Then we will pad zeros.
$paddedDays = str_pad($aday, 2, "0",STR_PAD_LEFT);
echo $paddedDays ;
?>
Let me know how it goes.
<?php
$date = "2007-11-13"; (or from DB)
$date = strtotime($date);
$aday = date("l",$date);
//Then we will pad zeros.
$paddedDays = str_pad($aday, 2, "0",STR_PAD_LEFT);
echo $paddedDays ;
?>
Let me know how it goes.
Last edited by binoj_daniel : Nov 13th, 2007 at 1:00 pm.
•
•
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation:
Rep Power: 2
Solved Threads: 20
Or, to use the MySQL functions, you could do ...
Then the solution is more general, and could be used if you were using Perl or PHP or whatever.
mysql> select date_format("2007-1-1","%Y-%m-%d");
+------------------------------------+
| date_format("2007-1-1","%Y-%m-%d") |
+------------------------------------+
| 2007-01-01 |
+------------------------------------+
1 row in set (0.25 sec)Then the solution is more general, and could be used if you were using Perl or PHP or whatever.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Dec 2006
Location: United States
Posts: 613
Reputation:
Rep Power: 3
Solved Threads: 15
•
•
Join Date: Dec 2006
Location: United States
Posts: 613
Reputation:
Rep Power: 3
Solved Threads: 15
What php code did you try?
Used this for putting the date back into the db so I didn't actually need to pull it out with the zero.
php Syntax (Toggle Plain Text)
if ($_GET['startDay'] = $row[0]) { $day = $_GET['startDay']; if ($day < 10) { $startDay = "0".$day; } else { $startDay = $_GET['startDay']; } } else { $startDay = $_POST['startDay']; }
Last edited by Venom Rush : Nov 15th, 2007 at 11:35 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- date problem (Visual Basic 4 / 5 / 6)
- converting date from form to field in access (Visual Basic 4 / 5 / 6)
- Inserting date in format DD-MM-YYYY in MySQL (MySQL)
- Displaying # value in date field in a data grid. (VB.NET)
- reading a date field out to a jTable component (Java)
- Ms Access 2003-How do I put a calender inside a form so user can pick date from month (MS Access and FileMaker Pro)
- embedded date formula for VB or Access (Visual Basic 4 / 5 / 6)
Other Threads in the MySQL Forum
- Previous Thread: what lecense
- Next Thread: Theoretical Question



Linear Mode