How to display date in kurdish using php - php

In php the date() function displays the date. But I have to display the date in kurdish language.. any one help me.
for example ..have to display the date like this
٢\١٢\٢٠١٤

As your Q is tagged WordPress, you can use date_i18n() to retrieve the date in localized format, based on timestamp:
echo date_i18n( get_option( 'date_format' ), time() )

You need to encode the given string to whatever charset you are using.
This is not bound to kurdish but to any language which cannot be displayed by your systems defauld charset.

Related

Get wordpress post publish date in format 2015-02-05T09:20:00+08:00

I want to get WordPress post publish date in the format,
2015-02-05T09:20:00+08:00
I have tried,
<?php echo get_the_date(); ?>
But it shows date in different format.
You need to specify the format you want when you call the get_the_date() function.
For the ISO format you want you need 'c', like this:
get_the_date('c') will print the format your looking for.
Go to the WordPress documentation if you want to read more on date and time formatting.
Go to Settings -> General, in Date Format section select Custom: and write c in text input. Save Changes!

Convert timestamp to Wordpress default language

I am bumping against a language barrier when I try to push out out meta data.
$string_date = implode (';', get_post_meta( get_the_ID(), 'dbt_opleverdatum' ) );
$format = get_option( 'date_format' );
$string_date = date($format, $string_date)
Since I save the meta data as a php time stamp, its being put away as a 1451865600 for example (which is january 4th 2016). I pick it up, and put it out via a date stamp which put it down for me as 4 January 2016
However, the whole site is run in Dutch and as I am looking through the code I notice the functions get_the_date() which retrieves the date of posting. But that will output 4 januari 2016 because that goes via the settings in Wordpress it self. It notices the wordpress is in Dutch and takes that in account.
Is there a function I can put my PHP date through that as well, so my date will be propperly shown in Dutch, instead of English?
From: http://php.net/manual/en/function.date.php:
To format dates in other languages, you should use the setlocale() and
strftime() functions instead of date().
$ts = 1451865600;
$lang = get_option('WPLANG');
setlocale(LC_TIME, $lang);
$format2 = '%e %B %G';
$string_date = strftime($format2, $ts);
Unfortunately I don't know how to convert the date_format in the options to the format string of strftime, but if it's your plugin, then you can change it to mean the format for strftime, or if you use it in other places as well, then add another option for this.
Notice: using setlocale changes the locale globally, so it might be necessary to revert the chage after the call to strftime:
$current_locale = setlocale(LC_TIME, "0");
setlocale(LC_TIME, $lang);
...
setlocale(LC_TIME, $current_locale);

strtotime display one date before in php

I've a date in the format dd/mm/YYYY. Eg: 25/06/2015.
I want convert it to timestamp. I've added the following code to implement this;
$timestamp = strtotime( str_replace( '/', '-', '25/06/2015' ) );
It creates timestamp, but when I convert that timestamp I can see that it is one day before. When I execute the above code, I got the timestamp value "1435183200". When I convert this I got the previous date "24/06/2015".
If anybody knows the solution to fix this, please help.
I think you have the default timezone configured in PHP. Try switching your timezone. Use:
date_default_timezone_set('your_timezone_here');
For a list of supported timezones, go to http://php.net/manual/en/timezones.php

What format of a timestamp is this?

I have to make some changes on an wordpress plugin.
The plugin gives back this timestamp format: 1364495828.1500
What's the name of this format and how can I change it to DD/MM/YYYY - HH:MM???
I am using PHP
Thanks!
This is a UNIX timestamp to a resolution of 100 microseconds.
Try this to get it into a DATETIME format in your SQL statement.
FROM_UNIXTIME(1364495828.1500)
You can also give a second parameter to the function containing a DATE_FORMAT string, and get the date string you want. For example, this gets you a timestamp string like 16/06/2013 14:25
FROM_UNIXTIME(1364495828.1500, '%d/%m/%Y - %H:%i')
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
But, if you're working in WordPress, you may prefer to do this in PHP. If you use PHP code like this you'll use the WordPress date format and time format settings chosen by the user, and get the the kind of result your user expects.
$timestring = date_i18n( get_option( 'date_format' ), '1364495828.1500' ) .
' ' .
date_i18n( get_option( 'time_format' ), '1364495828.1500' );
These are chosen on the general settings page in WordPress's administrative interface.
It's just the result of:
$ts = microtime(true); // 1368731778.7964 as I write this
a standard UNIX timestamp with microseconds included.
try this(didn't test it):
date('d-m-Y - H:i',strtotime('1364495828.1500'));
this code tries to find out time it is en set it to a data and the date function format it for you

Wordpress date format

Is it possible to use some constant strings in date formatting in Wordpress?
something like:
year:Y, month:F
which would translate to:
year:2012, month:February
Yes that's possible. Wordpress uses the php: date-function to format the date, thus you can use the following format on the general settings page of your blog.
To use constant string you will need to escape every character that should not be parsed as part of the date:
\y\e\a\r: Y, \m\o\n\t\h: F
This formatting string will result in "year: 2013, month: February".
See also the Wordpress Codex on formatting date and time.

Categories