English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Could anybody help me to find a php function date convertor to others dates: as like arabic, gregorian,jalaali,ethiopian and so on. http://www.funaba.org/en/calendar-conversion.cgi

2006-07-08 03:28:56 · 4 answers · asked by rezamilanx 2 in Computers & Internet Programming & Design

4 answers

You can use the date(string format, int timestamp) function to print it in various formats, but I'm not sure that it will have formats for all of those.

http://www.php.net/manual/en/function.date.php

2006-07-08 03:33:16 · answer #1 · answered by John J 6 · 0 0

just use the date(format [, unix timestamp]) function. You can pretty much create any format with that function as long as you don't need to use the names of the days and months (e.g. Monday, July, etc...). With numbers, you can do anything.
Example: you need the today's date in y-m-d format. The function call would be something like this: $now = date("Y-m-d"). How simple is that? date("dmY") would stick the numbers together.


If you do need the names or days and months, then you have to do it separately in your own function.
For the day of the week for example (Monday-Sunday), don't use "D" as the argument because that would be in english. What you need to do is to find the numerical representation of the day, and that would be "w" (Sunday would return you "0" and Saturday would return "6"). Then using a reference array to translate the day into your language's name for the day

$dayOfTheWeekToBeTranslated = date("w");
//you now have the number
$RefArray = new Array("Sunday in arabic", "Monday in arabic", etc...);
$translatedNameOfTheDay = $RefArray [$dayOfTheWeekToBeTranslated];

Finally concatenate it with the rest of your date string for display.
Tip: always use english if you're going to store it. Only use other languages to display.

hope this helps

----
Edit: You might need to type-cast it because the date function returns a string instead of an integer. PHP might understand it without type-casting though, so you need to test it out.
cheers

2006-07-08 12:34:58 · answer #2 · answered by rice kid 4 · 0 0

i don't think there's a function like that! you have to create it yourself! so depending on the country, it would know how many hours (or so) to add to make the actual conversion!

2006-07-08 10:33:14 · answer #3 · answered by Kheme 5 · 0 0

I am but i live in Russia

2006-07-08 10:33:04 · answer #4 · answered by Minna35 1 · 0 0

fedest.com, questions and answers