close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How to Display Nothing or 0000-00-00 When the DB Date Column is Empty

Thread began 2/07/2016 5:23 am by salaroche | Last modified 2/09/2016 12:58 pm by Ray Borduin | 413 views | 8 replies |

salaroche

How to Display Nothing or 0000-00-00 When the DB Date Column is Empty

Hi:

There are date fields in a particular page which don't always have data in them, yet DW always displays some value in them. As it is, when the date column is empty (no date has been previously entered in the DB) DW displays 01-01-1970 in the date field, which I suppose is the default date. I have tried entering 0000-00-00 as the default value in the DB but DW still displays that default date.

Is there any way to avoid that? Is there any way to have DW leave that page field blank or display zeros when no date has been entered in the DB?

Thank you for your attention

Sign in to reply to this post

Ray BorduinWebAssist

What code are you using to display the date on the page? If you post that I can show you how to add an IF statement to it so it won't show when blank.

Sign in to reply to this post

salaroche

Ray:

The code I'm using is this one:

<input name="adv1Date" type="text" id="adv1Date" value="<?php echo(date("d.m.Y", strtotime($row_WADApslip['adv1Date']))); ?>" size="10" readonly="readonly" />

Just in case, attached please find a copy of one of the pages that uses that code.

Attached Files
pslip_Detail.php
Sign in to reply to this post

Ray BorduinWebAssist

Use:
value="<?php echo(($row_WADApslip['adv1Date'])?date("d.m.Y", strtotime($row_WADApslip['adv1Date'])):""); ?>"

Sign in to reply to this post

salaroche

Ray:

I replaced the code as you suggested but I'm still getting 01.01.1970

Sign in to reply to this post

Ray BorduinWebAssist

Odd.. write the value to the page getting returned by the database without date formatting like:

value= "<?php echo($row_WADApslip['adv1Date']); ?>"

What does that value look like?

Sign in to reply to this post

salaroche

It shows 1970-01-01

Sign in to reply to this post

Ray BorduinWebAssist

Then I guess try:

value="<?php echo(($row_WADApslip['adv1Date'] != "1970-01-01")?date("d.m.Y", strtotime($row_WADApslip['adv1Date'])):""); ?>"

Sign in to reply to this post

salaroche

Ray:

It seems to be working. There are other similar instances in other programs where the date that appears is not 1970-01-01, but now I'll have an idea of how to go about it.

Many thanks.

Sign in to reply to this post

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

Content

rating

Layout

rating

Ease of use

rating

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...