CodeIgniter: A non well formed numeric value encountered - codeigniter

I'm working with CI and it is successfully echoing the proper expire date, but I am also getting this error:
A non well formed numeric value encountered
$expire_datetime = date('g:ia \o\n l jS F Y',strtotime($row->created, "+2weeks"));
echo $expire_datetime;

All you coding is correct. problem is with +2weeks. When you use strtotime() function you need to keep <space> on between text(+2<SPACE>weeks).
Examples(from W3Schools)
<?php
echo(strtotime("now") . "<br>");
echo(strtotime("3 October 2005") . "<br>");
echo(strtotime("+5 hours") . "<br>");
echo(strtotime("+1 week") . "<br>");
echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "<br>");
echo(strtotime("next Monday") . "<br>");
echo(strtotime("last Sunday"));
?>
So your Final Well form code is
$expire_datetime = date('g:ia \o\n l jS F Y',strtotime($row->created, "+2 weeks"));

strtotime() function requires relative date format in first argument. Second argument is optional and can be unix time stamp.

Related

whereBetween not working with Carbon::parse()->subDay() & current day laravel

i want to query whereBetween two dates with time
here is code which is working fine
whereBetween('created_at', [now()->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), now()->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
but this code is not working
$date = Carbon::parse($request->date);
whereBetween('created_at', [$date->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), $date->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]
please also explain thank you
Calling subDay() on the $date object will set the time in the Carbon object back 24 hours. So in the upper boundary for whereBetween, you are not using the request date, but the one 24 hours back.
To achieve what you want, you need to copy the object before changing it:
...->whereBetween('created_at', [$date->copy()->subDay()->format('Y-m-d') . ' ' . $tgame->start_time->format('H:i:s'), $date->format('Y-m-d') . ' ' . $tgame->end_time->format('H:i:s')]

Sugarcrm / Suitecrm smarty preg_replace

Ive got the error below
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\suitecrm\include\Smarty\Smarty_Compiler.class.php on line 268
I have changed the PHP.ini file to stop showing deprecated errors, but it still shows up
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
I've also changed the line in the Smarty_Compiler.class
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
But its not working..
Please advise
I found that and it seems working:
Replace lines from line 262 with:
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search,
function($m) {
return "{php ".str_repeat("\n", substr_count($m[0], "\n"))."}";
},
$source_content);
I have resolved this issue by replacing the code in include/Smarty/Smarty_Compiler.class.php file. I replaced the code on line numbers from 262 to 268 with the below mentioned code. After that delete all the files which are in the cache folder and reload the page. This issue will be resolved.
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
My solution:
$source_content = preg_replace_callback($search,
function($m) {
return $this->_quote_replace($this->left_delimiter) .
"php ".str_repeat("\n", substr_count($m[0], "\n")) .
$this->_quote_replace($this->right_delimiter);
},
$source_content);
In solution from Axel De Acetis I miss using of function $this->_quote_replace.
In solution from Sandeep Shivhare I dont like the number 1 in $matches[1], it references wrong string.

grocery CRUD list thumbnail size

Is there a way to adjust the size of gorcery CRUD's list thumbnails?
The way it is now it's just silly big, and breaks the table flow.
If possible, it would be nice to have a PHP solution or grocery CRUD setting for this; if not - a CSS rule would be ok, I guess.
Same issue I came across, I'm sure it's a quick-and-dirty solution but it worked for me.
Open your application/library/Grocery_CRUD.php
Download timthumb from here
Place timthumb.php in Root directory (in same directory
level cache folder should be there)
Find function change_list_value
Find around line number 333 in Grocery_CRUD.php
$file_url_anchor .= 'class="image-thumbnail">';
Replace with... following
$file_url_anchor .= ' class="image-thumbnail"><img src="' . base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3' .'" height="50px">';
Again Find function get_upload_file_input
Find around line number 2545 in Grocery_CRUD.php
$input .= $is_image ? " $image_class'>" : "' target='_blank'>$value";
Replace with following
$input .= $is_image ? " $image_class'><img src='".base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3'."' height='50px'>" : "' target='_blank'>$value";
Hope this would help you to get rid of ugly size in your list as well as add/edit forms

Upside down text

How would you design a program that will take in a string of lower case letters and produce the string upside down?
so if I type in home
i get ǝɯoɥ upside down.
I've tried looking for in the book to get started, but nothing.
Try this, a bit of a brute-force approach but works quite well for uppercase, lowercase and number characters - all other characters are presented just as they come:
(define upside-map '#hash(
(#\a . #\ɐ) (#\b . #\q) (#\c . #\ɔ) (#\d . #\p) (#\e . #\ǝ) (#\f . #\ɟ)
(#\g . #\ƃ) (#\h . #\ɥ) (#\i . #\ı) (#\j . #\ɾ) (#\k . #\ʞ) (#\l . #\ן)
(#\m . #\ɯ) (#\n . #\u) (#\o . #\o) (#\p . #\d) (#\q . #\b) (#\r . #\ɹ)
(#\s . #\s) (#\t . #\ʇ) (#\u . #\n) (#\v . #\ʌ) (#\w . #\ʍ) (#\x . #\x)
(#\y . #\ʎ) (#\z . #\z) (#\A . #\∀) (#\B . #\𐐒) (#\C . #\Ɔ) (#\D . #\◖)
(#\E . #\Ǝ) (#\F . #\Ⅎ) (#\G . #\⅁) (#\H . #\H) (#\I . #\I) (#\J . #\s)
(#\K . #\⋊) (#\L . #\˥) (#\M . #\W) (#\N . #\N) (#\O . #\O) (#\P . #\Ԁ)
(#\Q . #\Ό) (#\R . #\ᴚ) (#\S . #\S) (#\T . #\⊥) (#\U . #\∩) (#\V . #\Λ)
(#\W . #\M) (#\X . #\X) (#\Y . #\⅄) (#\Z . #\Z) (#\0 . #\0) (#\1 . #\Ɩ)
(#\2 . #\ᄅ) (#\3 . #\Ɛ) (#\4 . #\ㄣ) (#\5 . #\ϛ) (#\6 . #\9) (#\7 . #\ㄥ)
(#\8 . #\8) (#\9 . #\6)))
(define (flip-string str)
(list->string
(map (lambda (c)
(hash-ref upside-map c (const c)))
(reverse (string->list str)))))
For example:
(flip-string "Hello World")
=> "pןɹoM oןןǝH"
For reference, I used this conversion table taken from Wikipedia. The above solution has a little wrinkle: I couldn't manage to make it work for the 𐐒 character (flipped B), with unicode value of #\u10412 - because it won't fit in a 16-bit unicode character, so it can't be represented. I wasn't aware that Racket doesn't support characters with an encoding requiring more than 16 bits.
first of all your website must support Unicode, Unicode consists thousands of characters, the first 127 of Unicode are ASCII. It is possible to create text that appears to be upside down by converting character by character to a Unicode sign that looks like the upside down version of the character, for example to convert "6" you can use "9" but the flipped version of "f" is "ɟ", which is a Latin character with Unicode number 607 (hex code 025F)
technically, you need two text area boxes, one for the original text and the other one for the flipped text, also you need a Javascript, use the onkeyup Javascript hook in the first text box to call an upsideDownText() function each time a key is released like this:
<textarea rows="5" cols="70" id="src" onkeyup="upsideDownText()"></textarea>
then do the text processing in the upsideDownText() Javascript function like this:
<script type="text/javascript">
function upsideDownText() {
var srcText = document.getElementById( 'src' ).value.toLowerCase();
var out = '';
for( var i = srcText.length - 1; i >= 0; --i ) {
var ch = srcText.charAt( i );
if( ch == 'a' ) {
out += '\u0250' }
} else if( ch == 'b' ) {
out += 'q' }
} else if( ch == 'c' ) {
out += '\u0254'
// etc....
} else {
out += ch
}
}
document.getElementById( 'dest' ).value = out;
}
</script>
get the content of the text box identified by id="src" and convert the string to lowercase using the toLowerCase() method. Then loop through the string, character by character, starting from the end of the string. A big if-then-else-if block handles the character conversion. finally push the converted string into the text box identified by id="dest", which is the lower text box.
you can find the full list of how doing this step by step from Source twiki.org

Codeigniter time showing as AM not PM

I am using the codeigniter time helper to echo the TIMESTAMP (CURRENT_TIMESTAMP) row of my mysql database.
The timestamp in my database in raw format is: 2011-11-15 14:40:45
When I echo the time in my view using the helper i get the following: 15/11/2011 02:40
My time now appears to be in AM. Why???
This is the code I use to echo the time:
$the_date = mdate('%d/%m/%Y %h:%i', strtotime($row->date))
echo $the_date
You need to change the format of your data when returning it from the database. Chage the lowercase h (%h) to a capital H (%H) to return 24-hour format rather than the 12 hour you're currently getting.
You're code should look like the below:
$the_date = mdate('%d/%m/%Y %H:%i', strtotime($row->date))

Resources