By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

php "date()" function

P: n/a
When I used the "date("nj")" function to generate an invoice, about 1
out of 500 times, nothing comes up

<?php
$invoicedate = date("nj");
?>
<html><head></head><body>
Invoice date:
<?php
print $invoicedate;
?>
</body></html>

So, when I noticed some invoices were missing dates, I tried this:

<?php
$invoicedate = date("nj");
?>
<html><head></head><body>
Invoice date:
<?php
if (!invoicedate) {
$invoicedate = date("nj");
}
print $invoicedate;
?>
</body></html>

But, still, 1 out of 500 times, no date prints to browser.

My question is: On some web-servers, does the date() function not always
work? If not, then why not?

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Westcoast Sheri" <sh*********@nospamun8nospam.com> wrote in message
news:40***************@nospamun8nospam.com...
When I used the "date("nj")" function to generate an invoice, about 1
out of 500 times, nothing comes up

<?php
$invoicedate = date("nj");
?>
<html><head></head><body>
Invoice date:
<?php
print $invoicedate;
?>
</body></html>

So, when I noticed some invoices were missing dates, I tried this:

<?php
$invoicedate = date("nj");
?>
<html><head></head><body>
Invoice date:
<?php
if (!invoicedate) {
$invoicedate = date("nj");
}
print $invoicedate;
?>
</body></html>

But, still, 1 out of 500 times, no date prints to browser.

My question is: On some web-servers, does the date() function not always
work? If not, then why not?


This won't completely answer your question, but one problem I did notice in
your second example was that you left out the dollar sign $ in the if
statement on line 7:

if (!invoicedate) {

should be

if (!$invoicedate) {

- JP
Jul 17 '05 #2

P: n/a
kingofkolt wrote:
"Westcoast Sheri" <sh*********@nospamun8nospam.com> wrote in message
news:40***************@nospamun8nospam.com...
When I used the "date("nj")" function to generate an invoice, about 1
out of 500 times, nothing comes up

<?php
$invoicedate = date("nj");
?>
<html><head></head><body>
Invoice date:
<?php
print $invoicedate;
?>
</body></html>

So, when I noticed some invoices were missing dates, I tried this:

<?php
$invoicedate = date("nj");
?>
<html><head></head><body>
Invoice date:
<?php
if (!invoicedate) {
$invoicedate = date("nj");
}
print $invoicedate;
?>
</body></html>

But, still, 1 out of 500 times, no date prints to browser.

My question is: On some web-servers, does the date() function not always
work? If not, then why not?


This won't completely answer your question, but one problem I did notice in
your second example was that you left out the dollar sign $ in the if
statement on line 7:

if (!invoicedate) {

should be

if (!$invoicedate) {

- JP


Oops, just a typo in this newsgroup only, not in script.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.