close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Populate Recordset only if current DATE and TIME matches

Thread began 10/30/2009 7:01 am by info305726 | Last modified 11/02/2009 4:32 pm by info305726 | 2706 views | 17 replies


Hey guys,

Here's a couple of functions I wrote that I use in my core functions include file at the top of my pages... these are not exact (as they are for US date formatting) but could easily be modified for use in any format.

The first one is what I call goodDate - it currently takes database formatted date and returns the US date formatting of "M/D/YY".


function goodDate($datetochange) {
    $date_var = strtotime($datetochange);
    echo date('n/j/y', $date_var);

If you need to modify another variable with this, just chance the echo command to "return".

The second function was written so when a user is updating dates in a form, their submission will be changed from "M/D/YY" to the database format. By enabling a function to change the date, you don't have to rely on client or JS validation to actually handle the reformat allowing for easier validation of the input.


function dataDate($datetoconvert) {
    $dateDataDate = explode('/', $datetoconvert);
    if ($dateDataDate[2] >= 40 && $dateDataDate[2] <= 99) {
        $dateDataYear = '19'.$dateDataDate[2]; 
    } else {
        $dateDataYear = '20'.$dateDataDate[2];
    if (strlen($dateDataDate[0]) == 1) {
        $dateDataMonth = '0'.$dateDataDate[0];
    } else {
        $dateDataMonth = $dateDataDate[0];
    if (strlen($dateDataDate[1]) == 1) {
        $dateDataDay = '0'.$dateDataDate[1];
    } else {
        $dateDataDay = $dateDataDate[1];
    $dataDateFinal = $dateDataYear.'-'.$dateDataMonth.'-'.$dateDataDay;
    return $dataDateFinal;

To use this... just take your post variable as it gets entered into the database and wrap it with dataDate(variable).

Again, this was set up to handle US dates but as you can see, could be easily modified for any format.



Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...