Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hello, forgive me for reopening the topic after so long closed. It turns out that just today your help was very useful for me, thanks!
I have a very similar question, which is: How to make the dreamweaver grab the date from the database as 'yyyy-mm-dd' and shows on screen as 'dd / mm / yyyy'?
Is this possible?
Thank you!
Copy link to clipboard
Copied
You would use the same basic concept.
Explode the string by characters then create a new string with array items from the exploded result. Assuming your date column is named 'date' in the database you'd perform a query to get the value of the date's row. Then explode the string and create a new string of exploded result.
$mysql_date = explode('-', $mysql_row['date']);
$onscreen_date = "$mysql_date[2]/$mysql_date[1]/$mysql_date[0]";
best,
Shocker
Copy link to clipboard
Copied
hahahah thanks!
After asking the question here, I worked for a while in the code and I did something very similar to what you told me, look:
<input name="datainicial_diaria" type="text" value="
<?php
$datainicial=$row_seleciona_diarias['datainicial_diaria'];
$d=explode("-",$datainicial);
$datainicial=$d[2]."/".$d[1]."/".$d[0];
echo $datainicial;
?>
">
Is that when you do not have much familiarity with the code generated by dreamweaver, easy things can seem complicated! Thank you!
Copy link to clipboard
Copied
If you are just going to echo the date, the above solutions are fine, but if you need to do various things with the date, such as perform calculations, then it is useful to use the built-in PHP DateTime class instead of the procedural methods. At first it seems like it takes extra steps to do things with the class, but for some applications it's brilliant.
Copy link to clipboard
Copied
mateusaziani wrote:
hahahah thanks!
After asking the question here, I worked for a while in the code and I did something very similar to what you told me, look:
<input name="datainicial_diaria" type="text" value="
<?php
$datainicial=$row_seleciona_diarias['datainicial_diaria'];
$d=explode("-",$datainicial);
$datainicial=$d[2]."/".$d[1]."/".$d[0];
echo $datainicial;
?>
">
Is that when you do not have much familiarity with the code generated by dreamweaver, easy things can seem complicated! Thank you!
It is not recommended to process data via a form value if the data can simply be processed directly by a query. What I mean to say is that you should be processing your date directly in the processing script instead of sending the value through an input field, which can compromise the data.
best,
Shocker
Copy link to clipboard
Copied
you should be processing your date directly in the processing script instead of sending the value through an input field
There are forms where I populate an input field with a default date, which can then be changed by the person filling out the form, such as arrival and departure dates for a stay at a resort. That might be what the poster is trying to do.
Copy link to clipboard
Copied
Rob Hecker2 wrote:
There are forms where I populate an input field with a default date, which can then be changed by the person filling out the form, such as arrival and departure dates for a stay at a resort. That might be what the poster is trying to do.
Are those forms where you populate an input field from data that is originally retrieved from MySQL and reformatted? That seems like an unlikely scenario and sloppy programming.
best,
Shocker
Copy link to clipboard
Copied
Shocker, let's say you decide to attend a weeklong retreat titled HOW NOT TO BE A NUISANCE ON INTERNET FORUMS. The registration form is prepopulated with the recommended arrival date of October 3, but you decide to arrive two days earlier, on Oct 1, so you have the ability to change the date and recalculate your costs. Because the retreat center hosts over 500 retreats per year, registration forms are pre-populated with the dates, costs, and other details of the particular retreat being registered for, which is all stored in the database so a single registration form script can be used for all possible variations.
Copy link to clipboard
Copied