My jSon date format:
release_date: "1426153440",
When I use like this, its done but has a format problem:
{$info.release_date}
Generate to:
1426153440
How can I solve format problem in tpl files? Thank you.
You can use date_format, with it you can combine the conversion specifiers available in strftime().
Example:
{$info.release_date|date_format:"%Y-%m-%d"}
Related
I got this format from the wp_postmate table. How can I convert it to a readable format?
a:11:{i:2;a:3:{s:10:"field_name";s:7:"Address";s:11:"field_value";s:47:" govindpuri kalkaji, new delhi-110019";s:11:"field_label";N;}i:3;a:3:{s:10:"field_name";s:4:"City";s:11:"field_value";s:9:"NEW DELHI";s:11:"field_label";N;}i:6;a:3:{s:10:"field_name";s:14:"DateOfPurchase";s:11:"field_value";s:10:"2020-09-15";s:11:"field_label";N;}i:5;a:3:{s:10:"field_name";s:5:"Email";s:11:"field_value";s:31:"sharikbillionaire#gmail.com";s:11:"field_label";N;}i:1;a:3:{s:10:"field_name";s:9:"Last-name";s:11:"field_value";s:5:"matin";s:11:"field_label";N;}i:8;a:3:{s:10:"field_name";s:16:"Nameoftheproduct";s:11:"field_value";s:10:"Mohd Afzal";s:11:"field_label";N;}i:7;a:3:{s:10:"field_name";s:7:"OrderId";s:11:"field_value";s:10:"1236547896";s:11:"field_label";N;}i:4;a:3:{s:10:"field_name";s:7:"PinCode";s:11:"field_value";s:6:"110019";s:11:"field_label";N;}i:10;a:3:{s:10:"field_name";s:14:"mc4wp_checkbox";s:11:"field_value";s:2:"No";s:11:"field_label";N;}i:9;a:3:{s:10:"field_name";s:10:"reviewfile";s:11:"field_value";s:32:"e570b19fc4a826c333e4ac78ee19393c";s:11:"field_label";N;}i:0;a:3:{s:10:"field_name";s:9:"your-name";s:11:"field_value";s:4:"mohd";s:11:"field_label";N;}}
The above data was stored in a serialized format so you can simply use unserialize() to get the data in an array.
I am trying to encode the number 17342846 but every time i get 1.7342846e+07 instead of the int format. i am using
$var = 17342846;
json_encode((int)$var);
in php trying to get it to work but still no luck. Any help would be appreciated.
just encode it as string format then convert it later.
json_encode($var + '');
I want to format a variable as currency before displaying on the template. Now I know I can create a language specific dictionary file and use it to format it as currency, but is there a way to do it directly?
Yes, you can use the format() method:
echo $f3->format('Price: {0,number,currency}',29.90);//Price: $29.90
See here for more examples.
From within a template, the syntax would be:
{{'Price: {0,number,currency}',#price|format}}
I've got a JSON variable ($epoch) which contains the date in epoch (1370777177), and I'd like to convert it to the following format and output it:
date "+%F %R" -ud #1370777177
which returns:
2013-06-09 11:26
So I figure using php to echo the command is one way to do it. Is there a way to convert the epoch to the format above and append it to a DIV using JS? That might be a lot easier. I've tried creating a PHP variable which encodes the JSON var:
$date = json_encode($epoch);
echo exec ('date "+%F %R" -ud #%date');
But that doesn't work.
echo json_encode($epoch)
returns 'null'. The JSON variable is in a external .js file.
Is there a way to convert the epoch to the format above and append it to a DIV using JS?
Yes, there is.
Also exec() will scale awesomely.
I have a date I need to replicate in PHP. I just want to know if there is some sort of shortcode for it.
2013-05-09T15:23:59.802Z
It is ISO 8601. In PHP you would make it using:
echo date('c'); // as of PHP 5
See date()
This one liner achieves what you are asking.
echo date_format(date_create("#".$unix_timestamp, timezone_open('UTC')), 'Y-m-d\TH:i:s.000\Z');
Output:
2013-05-09T15:23:59.000Z