Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Error: Non-Numeric Value Encountered

Asked Modified Viewed 861 times
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
asked
Senior Member

Hey guys why does this return a non-numeric value?
function localdate($format, $timestamp)
{
 global $settings;
 
 return strftime($format, $timestamp + fusion_get_settings('timeoffset')*3600);
}
I am working on afosters AUTONEWS infusion from v7 and upgrading it to function on v9
0 replies

6 posts

K
karrak
K
karrak 32
Van mi sosem változik..smile
  • Senior Member, joined since
  • Contributed 310 posts on the community forums.
  • Started 94 threads in the forums
  • Answered 1 question
answered
Senior Member

fusion_get_settings('timeoffset') == Europe/Belgrade

 return strftime($format, $timestamp);
0 replies
R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

As already karrak indicated fusion_get_settings('timeoffset') is string.

However try to avoid using strftime, it has been deprecated since php 8.1. Core already has this date formatting function that already has time zone calculation https://www.php-fusion.co.uk/docs/php...s/showdate

Code https://github.com/PHPFusion/PHPFusio...1832-L1903
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
answered
Senior Member

I could really use some more help with this old autonews infusion code. My modified function doesn't work right and still gives an error that says a "Non well formed numeric value encountered"
This is the original function

// Utility function to return a formatted local date
function localdate($format, $timestamp)
{
 global $settings;
 return strftime($format, $timestamp + $settings['timeoffset']*3600);
}

This my modified function

// Utility function to return a formatted local date
function localdate($format, $timestamp)
{
 global $settings;
   $format = showdate($settings['shortdate'], TIME, ['tz_override' => $settings['timeoffset']]);
 return strftime($format, $timestamp);
}

These are the 3 localdate calls in the script with locale define for strftime
Locale that defines strftime

$locale['AN010'] = '%a, %b %e at %H:%M'; // Date-format used for strftime(...)
$locale['AN011'] = '%e %b %H:%M';       // Short date-format used for strftime(...) in autonews_panel only

<td>".localdate($locale['AN010'], $date)."</td>
localdate($locale['AN010'], $data['timestamp']),
".localdate($locale['AN010'], $autonews_settings['ts_thissend'])."

I need to somehow completely convert it to Fusions time keeping parameters.
Edited by Grimloch on 20-02-2022 19:48,
0 replies
R
Anonymous User
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions
answered
Veteran Member

You misunderstood that code or documentation. If you use showdate() function then don't use strftime() because showdate already formatting time.

So only this you need,
$locale['AN010'] = '%a, %b %e at %H:%M'; // Date-format used for strftime(...)
$locale['AN011'] = '%e %b %H:%M'; // Short date-format used for strftime(...) in autonews_panel only

<td>".showdate($locale['AN010'], $date)."</td>
showdate($locale['AN010'], $data['timestamp']),
".showdate($locale['AN010'], $autonews_settings['ts_thissend'])."


If you use on many places your current function then you can simply do this and result will be the same
function localdate($format, $timestamp) {
 return showdate($format, $timestamp);
}


It is clearly described in documentation and there is also an example usage https://www.php-fusion.co.uk/docs/php...e#examples
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
answered
Senior Member

Thanks RobiNN. I think that did the trick it seems to work correctly now. Onward to try and solve the "trying to access array offset on value of null" errors.
Edited by Grimloch on 20-02-2022 21:07,
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
answered
Senior Member

Is there a good guide for converting v7 user fields to v9? My userfield in question is a simple Yes(1) No(0) setup. There are no existing userfields that are like that to model from.
Edited by Grimloch on 21-02-2022 04:55,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 6 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

K
K
karrak 32
Van mi sosem változik..smile
  • Senior Member, joined since
  • Contributed 310 posts on the community forums.
  • Started 94 threads in the forums
  • Answered 1 question
G
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Started this discussions
  • Answered 2 questions
R
R
Anonymous User 367
  • Veteran Member, joined since
  • Contributed 939 posts on the community forums.
  • Started 2 threads in the forums
  • Answered 20 questions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet