How do you convert a Unix timestamp to Jalali/Shamsi/Persian format? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!convert date from gergorian to shamsihow to convert linux timestamp to persian/jalali in react native?How to convert decimal to hexadecimal in JavaScriptHow can I format numbers as dollars currency string in JavaScript?How do I format a Microsoft JSON date?How do you get a timestamp in JavaScript?How can I convert a string to boolean in JavaScript?How do you check if a variable is an array in JavaScript?Convert a Unix timestamp to time in JavaScriptHow to format a JavaScript dateA good date converter for Jalali Calendar in Java?Building DimDate in SSAS 2012 for Persian calendar (Shamsi or Jalali dates)

An adverb for when you're not exaggerating

What order were files/directories output in dir?

What does it mean that physics no longer uses mechanical models to describe phenomena?

Is there public access to the Meteor Crater in Arizona?

What is the meaning of 'breadth' in breadth first search?

Dyck paths with extra diagonals from valleys (Laser construction)

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

AppleTVs create a chatty alternate WiFi network

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?

The test team as an enemy of development? And how can this be avoided?

Misunderstanding of Sylow theory

How to write capital alpha?

Tannaka duality for semisimple groups

Why can't I install Tomboy in Ubuntu Mate 19.04?

Do I really need to have a message in a novel to appeal to readers?

What's the point of the test set?

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

How would a mousetrap for use in space work?

What does 丫 mean? 丫是什么意思?

Does the Mueller report show a conspiracy between Russia and the Trump Campaign?

Sum letters are not two different

Why are vacuum tubes still used in amateur radios?

Co-worker has annoying ringtone

Most bit efficient text communication method?



How do you convert a Unix timestamp to Jalali/Shamsi/Persian format?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!convert date from gergorian to shamsihow to convert linux timestamp to persian/jalali in react native?How to convert decimal to hexadecimal in JavaScriptHow can I format numbers as dollars currency string in JavaScript?How do I format a Microsoft JSON date?How do you get a timestamp in JavaScript?How can I convert a string to boolean in JavaScript?How do you check if a variable is an array in JavaScript?Convert a Unix timestamp to time in JavaScriptHow to format a JavaScript dateA good date converter for Jalali Calendar in Java?Building DimDate in SSAS 2012 for Persian calendar (Shamsi or Jalali dates)



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I'm developing a web App and I have a unix timeStamp.
I need to convert a unix date format to Jalali/Persian/Shamsi Calendar by using jQuery selectors and then convert it by using javascript library.

Something Like below code to convert Unix-Date to Jalali-Date:



<html>
<head>
<meta charset="utf-8">
</head>

<body>
<div class="Unix-Date">1494259627</div> <!-- Unix equal of 1396/2/18 -->
<div class="Jalali-Date"></div>

<script src="jquery.js"></script>
<script src="external-library.js"></script>
<script>
$(document).ready(function()
var UnixValue;
var JalaliValue;
UnixValue = $(".Unix-Date").html();
JalaliValue = new JalaliExternalFunction(UnixValue);
$(".Jalali-Date").text(JalaliValue);
);
</script>
</body>
</html>


I searched but didn't found any good library. Do you know a reliable and good library for converting (or creating dates in Jalali format from a unix timeStamp). I don't need your implementation or an algorithm, cause this issue is too buggy and has a lot of rules, I need a reliable solution.



Thank










share|improve this question






























    2















    I'm developing a web App and I have a unix timeStamp.
    I need to convert a unix date format to Jalali/Persian/Shamsi Calendar by using jQuery selectors and then convert it by using javascript library.

    Something Like below code to convert Unix-Date to Jalali-Date:



    <html>
    <head>
    <meta charset="utf-8">
    </head>

    <body>
    <div class="Unix-Date">1494259627</div> <!-- Unix equal of 1396/2/18 -->
    <div class="Jalali-Date"></div>

    <script src="jquery.js"></script>
    <script src="external-library.js"></script>
    <script>
    $(document).ready(function()
    var UnixValue;
    var JalaliValue;
    UnixValue = $(".Unix-Date").html();
    JalaliValue = new JalaliExternalFunction(UnixValue);
    $(".Jalali-Date").text(JalaliValue);
    );
    </script>
    </body>
    </html>


    I searched but didn't found any good library. Do you know a reliable and good library for converting (or creating dates in Jalali format from a unix timeStamp). I don't need your implementation or an algorithm, cause this issue is too buggy and has a lot of rules, I need a reliable solution.



    Thank










    share|improve this question


























      2












      2








      2


      3






      I'm developing a web App and I have a unix timeStamp.
      I need to convert a unix date format to Jalali/Persian/Shamsi Calendar by using jQuery selectors and then convert it by using javascript library.

      Something Like below code to convert Unix-Date to Jalali-Date:



      <html>
      <head>
      <meta charset="utf-8">
      </head>

      <body>
      <div class="Unix-Date">1494259627</div> <!-- Unix equal of 1396/2/18 -->
      <div class="Jalali-Date"></div>

      <script src="jquery.js"></script>
      <script src="external-library.js"></script>
      <script>
      $(document).ready(function()
      var UnixValue;
      var JalaliValue;
      UnixValue = $(".Unix-Date").html();
      JalaliValue = new JalaliExternalFunction(UnixValue);
      $(".Jalali-Date").text(JalaliValue);
      );
      </script>
      </body>
      </html>


      I searched but didn't found any good library. Do you know a reliable and good library for converting (or creating dates in Jalali format from a unix timeStamp). I don't need your implementation or an algorithm, cause this issue is too buggy and has a lot of rules, I need a reliable solution.



      Thank










      share|improve this question
















      I'm developing a web App and I have a unix timeStamp.
      I need to convert a unix date format to Jalali/Persian/Shamsi Calendar by using jQuery selectors and then convert it by using javascript library.

      Something Like below code to convert Unix-Date to Jalali-Date:



      <html>
      <head>
      <meta charset="utf-8">
      </head>

      <body>
      <div class="Unix-Date">1494259627</div> <!-- Unix equal of 1396/2/18 -->
      <div class="Jalali-Date"></div>

      <script src="jquery.js"></script>
      <script src="external-library.js"></script>
      <script>
      $(document).ready(function()
      var UnixValue;
      var JalaliValue;
      UnixValue = $(".Unix-Date").html();
      JalaliValue = new JalaliExternalFunction(UnixValue);
      $(".Jalali-Date").text(JalaliValue);
      );
      </script>
      </body>
      </html>


      I searched but didn't found any good library. Do you know a reliable and good library for converting (or creating dates in Jalali format from a unix timeStamp). I don't need your implementation or an algorithm, cause this issue is too buggy and has a lot of rules, I need a reliable solution.



      Thank







      javascript jquery date localization calendar






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 8 '17 at 17:08







      Mojtaba Reyhani

















      asked May 8 '17 at 14:36









      Mojtaba ReyhaniMojtaba Reyhani

      179217




      179217






















          2 Answers
          2






          active

          oldest

          votes


















          3














          I would suggest using moment.js (https://momentjs.com/) which is reliable JavaScript Time library that allows you to format your timestamp in JavaScript. Below is an example of how you can parse a timestamp and format it to whatever you want using it.



          //formatting Unix timestamp.
          var date = moment.unix(value).format("MM/DD/YYYY");


          You also tagged localization which can be done by using;



           var localeDate = moment(date).locale("LT");


          More examples can be found on there website.



          This in conjunction with https://www.npmjs.com/package/jalali-date will get you your jalali date.



          There is a moment.js extension for Persian here also https://www.npmjs.com/package/moment-jalaali (From moment to Jalali)



          Another Jalali conversion library https://www.npmjs.com/package/jalaali-js (To Jalai)



          An example fiddle using moment.js Jalali conversion from Unix Timestamp https://jsfiddle.net/uw82ozpd/9/



          Relevant code snippet with comments:



          var UnixValue;
          var JalaliValue;

          $(document).ready(function()

          //get the Unix Date from HTML
          var UnixValue = $(".Unix-Date").html();

          //Get a moment timestamp in the format simmilar to our next conversion
          var date = moment.unix(UnixValue).format("MM/DD/YY");

          //Convert from normal moment to our jalali moment exstension using j's as below
          var JalaliValue = moment(date).format('jYYYY/jM/jD');

          $(".Jalali-Date").text(JalaliValue);

          );





          share|improve this answer

























          • Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

            – Mojtaba Reyhani
            May 8 '17 at 15:01











          • Turns out there is also a moment extension for Persian, updating answer.

            – li x
            May 8 '17 at 15:05











          • Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

            – li x
            May 8 '17 at 15:08






          • 1





            It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

            – li x
            May 8 '17 at 17:51







          • 1





            You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

            – li x
            May 8 '17 at 17:53


















          2














          I have these simple functions:



          function convertTimeStampToJalali(timestamp)
          var date = new Date(timestamp);
          if(!date)
          return false;
          return ( gregorian_to_jalali(date.getFullYear(),(date.getMonth()+1),date.getDate()) );
          //end of function convertTimeStampToJalali

          function gregorian_to_jalali(gy,gm,gd)
          g_d_m=[0,31,59,90,120,151,181,212,243,273,304,334];
          if(gy > 1600)
          jy=979;
          gy-=1600;
          else
          jy=0;
          gy-=621;

          gy2=(gm > 2)?(gy+1):gy;
          days=(365*gy) +(parseInt((gy2+3)/4)) -(parseInt((gy2+99)/100)) +(parseInt((gy2+399)/400)) -80 +gd +g_d_m[gm-1];
          jy+=33*(parseInt(days/12053));
          days%=12053;
          jy+=4*(parseInt(days/1461));
          days%=1461;
          if(days > 365)
          jy+=parseInt((days-1)/365);
          days=(days-1)%365;

          jm=(days < 186)?1+parseInt(days/31):7+parseInt((days-186)/30);
          jd=1+((days < 186)?(days%31):((days-186)%30));
          return [jy,jm,jd];
          //end of function gregorian_to_jalali





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43850436%2fhow-do-you-convert-a-unix-timestamp-to-jalali-shamsi-persian-format%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            I would suggest using moment.js (https://momentjs.com/) which is reliable JavaScript Time library that allows you to format your timestamp in JavaScript. Below is an example of how you can parse a timestamp and format it to whatever you want using it.



            //formatting Unix timestamp.
            var date = moment.unix(value).format("MM/DD/YYYY");


            You also tagged localization which can be done by using;



             var localeDate = moment(date).locale("LT");


            More examples can be found on there website.



            This in conjunction with https://www.npmjs.com/package/jalali-date will get you your jalali date.



            There is a moment.js extension for Persian here also https://www.npmjs.com/package/moment-jalaali (From moment to Jalali)



            Another Jalali conversion library https://www.npmjs.com/package/jalaali-js (To Jalai)



            An example fiddle using moment.js Jalali conversion from Unix Timestamp https://jsfiddle.net/uw82ozpd/9/



            Relevant code snippet with comments:



            var UnixValue;
            var JalaliValue;

            $(document).ready(function()

            //get the Unix Date from HTML
            var UnixValue = $(".Unix-Date").html();

            //Get a moment timestamp in the format simmilar to our next conversion
            var date = moment.unix(UnixValue).format("MM/DD/YY");

            //Convert from normal moment to our jalali moment exstension using j's as below
            var JalaliValue = moment(date).format('jYYYY/jM/jD');

            $(".Jalali-Date").text(JalaliValue);

            );





            share|improve this answer

























            • Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

              – Mojtaba Reyhani
              May 8 '17 at 15:01











            • Turns out there is also a moment extension for Persian, updating answer.

              – li x
              May 8 '17 at 15:05











            • Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

              – li x
              May 8 '17 at 15:08






            • 1





              It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

              – li x
              May 8 '17 at 17:51







            • 1





              You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

              – li x
              May 8 '17 at 17:53















            3














            I would suggest using moment.js (https://momentjs.com/) which is reliable JavaScript Time library that allows you to format your timestamp in JavaScript. Below is an example of how you can parse a timestamp and format it to whatever you want using it.



            //formatting Unix timestamp.
            var date = moment.unix(value).format("MM/DD/YYYY");


            You also tagged localization which can be done by using;



             var localeDate = moment(date).locale("LT");


            More examples can be found on there website.



            This in conjunction with https://www.npmjs.com/package/jalali-date will get you your jalali date.



            There is a moment.js extension for Persian here also https://www.npmjs.com/package/moment-jalaali (From moment to Jalali)



            Another Jalali conversion library https://www.npmjs.com/package/jalaali-js (To Jalai)



            An example fiddle using moment.js Jalali conversion from Unix Timestamp https://jsfiddle.net/uw82ozpd/9/



            Relevant code snippet with comments:



            var UnixValue;
            var JalaliValue;

            $(document).ready(function()

            //get the Unix Date from HTML
            var UnixValue = $(".Unix-Date").html();

            //Get a moment timestamp in the format simmilar to our next conversion
            var date = moment.unix(UnixValue).format("MM/DD/YY");

            //Convert from normal moment to our jalali moment exstension using j's as below
            var JalaliValue = moment(date).format('jYYYY/jM/jD');

            $(".Jalali-Date").text(JalaliValue);

            );





            share|improve this answer

























            • Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

              – Mojtaba Reyhani
              May 8 '17 at 15:01











            • Turns out there is also a moment extension for Persian, updating answer.

              – li x
              May 8 '17 at 15:05











            • Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

              – li x
              May 8 '17 at 15:08






            • 1





              It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

              – li x
              May 8 '17 at 17:51







            • 1





              You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

              – li x
              May 8 '17 at 17:53













            3












            3








            3







            I would suggest using moment.js (https://momentjs.com/) which is reliable JavaScript Time library that allows you to format your timestamp in JavaScript. Below is an example of how you can parse a timestamp and format it to whatever you want using it.



            //formatting Unix timestamp.
            var date = moment.unix(value).format("MM/DD/YYYY");


            You also tagged localization which can be done by using;



             var localeDate = moment(date).locale("LT");


            More examples can be found on there website.



            This in conjunction with https://www.npmjs.com/package/jalali-date will get you your jalali date.



            There is a moment.js extension for Persian here also https://www.npmjs.com/package/moment-jalaali (From moment to Jalali)



            Another Jalali conversion library https://www.npmjs.com/package/jalaali-js (To Jalai)



            An example fiddle using moment.js Jalali conversion from Unix Timestamp https://jsfiddle.net/uw82ozpd/9/



            Relevant code snippet with comments:



            var UnixValue;
            var JalaliValue;

            $(document).ready(function()

            //get the Unix Date from HTML
            var UnixValue = $(".Unix-Date").html();

            //Get a moment timestamp in the format simmilar to our next conversion
            var date = moment.unix(UnixValue).format("MM/DD/YY");

            //Convert from normal moment to our jalali moment exstension using j's as below
            var JalaliValue = moment(date).format('jYYYY/jM/jD');

            $(".Jalali-Date").text(JalaliValue);

            );





            share|improve this answer















            I would suggest using moment.js (https://momentjs.com/) which is reliable JavaScript Time library that allows you to format your timestamp in JavaScript. Below is an example of how you can parse a timestamp and format it to whatever you want using it.



            //formatting Unix timestamp.
            var date = moment.unix(value).format("MM/DD/YYYY");


            You also tagged localization which can be done by using;



             var localeDate = moment(date).locale("LT");


            More examples can be found on there website.



            This in conjunction with https://www.npmjs.com/package/jalali-date will get you your jalali date.



            There is a moment.js extension for Persian here also https://www.npmjs.com/package/moment-jalaali (From moment to Jalali)



            Another Jalali conversion library https://www.npmjs.com/package/jalaali-js (To Jalai)



            An example fiddle using moment.js Jalali conversion from Unix Timestamp https://jsfiddle.net/uw82ozpd/9/



            Relevant code snippet with comments:



            var UnixValue;
            var JalaliValue;

            $(document).ready(function()

            //get the Unix Date from HTML
            var UnixValue = $(".Unix-Date").html();

            //Get a moment timestamp in the format simmilar to our next conversion
            var date = moment.unix(UnixValue).format("MM/DD/YY");

            //Convert from normal moment to our jalali moment exstension using j's as below
            var JalaliValue = moment(date).format('jYYYY/jM/jD');

            $(".Jalali-Date").text(JalaliValue);

            );






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 8 '17 at 15:53

























            answered May 8 '17 at 14:51









            li xli x

            2,32921632




            2,32921632












            • Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

              – Mojtaba Reyhani
              May 8 '17 at 15:01











            • Turns out there is also a moment extension for Persian, updating answer.

              – li x
              May 8 '17 at 15:05











            • Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

              – li x
              May 8 '17 at 15:08






            • 1





              It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

              – li x
              May 8 '17 at 17:51







            • 1





              You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

              – li x
              May 8 '17 at 17:53

















            • Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

              – Mojtaba Reyhani
              May 8 '17 at 15:01











            • Turns out there is also a moment extension for Persian, updating answer.

              – li x
              May 8 '17 at 15:05











            • Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

              – li x
              May 8 '17 at 15:08






            • 1





              It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

              – li x
              May 8 '17 at 17:51







            • 1





              You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

              – li x
              May 8 '17 at 17:53
















            Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

            – Mojtaba Reyhani
            May 8 '17 at 15:01





            Thank you so much for your help and reply, But it seems that moment.js only translate day and mount name to persian and the date still remain in gregorian.

            – Mojtaba Reyhani
            May 8 '17 at 15:01













            Turns out there is also a moment extension for Persian, updating answer.

            – li x
            May 8 '17 at 15:05





            Turns out there is also a moment extension for Persian, updating answer.

            – li x
            May 8 '17 at 15:05













            Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

            – li x
            May 8 '17 at 15:08





            Going to keep adding librarys that I find that could be useful, let me know if any of them work for you!

            – li x
            May 8 '17 at 15:08




            1




            1





            It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

            – li x
            May 8 '17 at 17:51






            It's likely that the very large script I inserted into the html caused it to be removed from jsfiddle, The code for moment jilali can be found here github.com/jalaali/moment-jalaali/blob/master/build/… copy that and save it in your directory and then use <script src="jalali-js.js"></script> (make sure to save the JS file as jalali-js'') Afterwards follow the instructions on my answer :-)

            – li x
            May 8 '17 at 17:51





            1




            1





            You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

            – li x
            May 8 '17 at 17:53





            You'll also need to include the base moment js which you can do by including <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> within your html.

            – li x
            May 8 '17 at 17:53













            2














            I have these simple functions:



            function convertTimeStampToJalali(timestamp)
            var date = new Date(timestamp);
            if(!date)
            return false;
            return ( gregorian_to_jalali(date.getFullYear(),(date.getMonth()+1),date.getDate()) );
            //end of function convertTimeStampToJalali

            function gregorian_to_jalali(gy,gm,gd)
            g_d_m=[0,31,59,90,120,151,181,212,243,273,304,334];
            if(gy > 1600)
            jy=979;
            gy-=1600;
            else
            jy=0;
            gy-=621;

            gy2=(gm > 2)?(gy+1):gy;
            days=(365*gy) +(parseInt((gy2+3)/4)) -(parseInt((gy2+99)/100)) +(parseInt((gy2+399)/400)) -80 +gd +g_d_m[gm-1];
            jy+=33*(parseInt(days/12053));
            days%=12053;
            jy+=4*(parseInt(days/1461));
            days%=1461;
            if(days > 365)
            jy+=parseInt((days-1)/365);
            days=(days-1)%365;

            jm=(days < 186)?1+parseInt(days/31):7+parseInt((days-186)/30);
            jd=1+((days < 186)?(days%31):((days-186)%30));
            return [jy,jm,jd];
            //end of function gregorian_to_jalali





            share|improve this answer



























              2














              I have these simple functions:



              function convertTimeStampToJalali(timestamp)
              var date = new Date(timestamp);
              if(!date)
              return false;
              return ( gregorian_to_jalali(date.getFullYear(),(date.getMonth()+1),date.getDate()) );
              //end of function convertTimeStampToJalali

              function gregorian_to_jalali(gy,gm,gd)
              g_d_m=[0,31,59,90,120,151,181,212,243,273,304,334];
              if(gy > 1600)
              jy=979;
              gy-=1600;
              else
              jy=0;
              gy-=621;

              gy2=(gm > 2)?(gy+1):gy;
              days=(365*gy) +(parseInt((gy2+3)/4)) -(parseInt((gy2+99)/100)) +(parseInt((gy2+399)/400)) -80 +gd +g_d_m[gm-1];
              jy+=33*(parseInt(days/12053));
              days%=12053;
              jy+=4*(parseInt(days/1461));
              days%=1461;
              if(days > 365)
              jy+=parseInt((days-1)/365);
              days=(days-1)%365;

              jm=(days < 186)?1+parseInt(days/31):7+parseInt((days-186)/30);
              jd=1+((days < 186)?(days%31):((days-186)%30));
              return [jy,jm,jd];
              //end of function gregorian_to_jalali





              share|improve this answer

























                2












                2








                2







                I have these simple functions:



                function convertTimeStampToJalali(timestamp)
                var date = new Date(timestamp);
                if(!date)
                return false;
                return ( gregorian_to_jalali(date.getFullYear(),(date.getMonth()+1),date.getDate()) );
                //end of function convertTimeStampToJalali

                function gregorian_to_jalali(gy,gm,gd)
                g_d_m=[0,31,59,90,120,151,181,212,243,273,304,334];
                if(gy > 1600)
                jy=979;
                gy-=1600;
                else
                jy=0;
                gy-=621;

                gy2=(gm > 2)?(gy+1):gy;
                days=(365*gy) +(parseInt((gy2+3)/4)) -(parseInt((gy2+99)/100)) +(parseInt((gy2+399)/400)) -80 +gd +g_d_m[gm-1];
                jy+=33*(parseInt(days/12053));
                days%=12053;
                jy+=4*(parseInt(days/1461));
                days%=1461;
                if(days > 365)
                jy+=parseInt((days-1)/365);
                days=(days-1)%365;

                jm=(days < 186)?1+parseInt(days/31):7+parseInt((days-186)/30);
                jd=1+((days < 186)?(days%31):((days-186)%30));
                return [jy,jm,jd];
                //end of function gregorian_to_jalali





                share|improve this answer













                I have these simple functions:



                function convertTimeStampToJalali(timestamp)
                var date = new Date(timestamp);
                if(!date)
                return false;
                return ( gregorian_to_jalali(date.getFullYear(),(date.getMonth()+1),date.getDate()) );
                //end of function convertTimeStampToJalali

                function gregorian_to_jalali(gy,gm,gd)
                g_d_m=[0,31,59,90,120,151,181,212,243,273,304,334];
                if(gy > 1600)
                jy=979;
                gy-=1600;
                else
                jy=0;
                gy-=621;

                gy2=(gm > 2)?(gy+1):gy;
                days=(365*gy) +(parseInt((gy2+3)/4)) -(parseInt((gy2+99)/100)) +(parseInt((gy2+399)/400)) -80 +gd +g_d_m[gm-1];
                jy+=33*(parseInt(days/12053));
                days%=12053;
                jy+=4*(parseInt(days/1461));
                days%=1461;
                if(days > 365)
                jy+=parseInt((days-1)/365);
                days=(days-1)%365;

                jm=(days < 186)?1+parseInt(days/31):7+parseInt((days-186)/30);
                jd=1+((days < 186)?(days%31):((days-186)%30));
                return [jy,jm,jd];
                //end of function gregorian_to_jalali






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 21:53









                a.miadiana.miadian

                47158




                47158



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43850436%2fhow-do-you-convert-a-unix-timestamp-to-jalali-shamsi-persian-format%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко