Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:47:16+00:00 2026-05-28T01:47:16+00:00

I am trying to display the date on android emulator browser. The current code

  • 0

I am trying to display the date on android emulator browser. The current code works fine on my PC web browser but it does not work properly on Android emulator web browser. Here are my two functions which I am using for this purpose.

dayOfWeek('Sun Jan 08 2012 02:00:00 GMT+0200 (FLE Standard Time)');
dayOfWeek = function (d) {
            var dayNames = new Array('SUN','MON','TUE','WED','THU','FRI','SAT');
            var day = toTimestamp(d);
            //alert(day);
            return dayNames[day.getDay()];
        }

        toTimestamp = function (strDate){
            return new Date(Date.parse(strDate));
        }

I am passing date in this format “Sun Jan 08 2012 02:00:00 GMT+0200 (FLE Standard Time)” which you can see in the code above as well.

PROBLEM:
The problem is on Android emulator browser it displays “undefined” where ti should appear name of the day such as “MON, TUE, WED” etc.

How can I solve this problem?

In the past I had the same problem then it was solved with following function. I got this function from somewhere on internet. But now it does not work here I do not know why.

function relative_time(date_str) {
if (!date_str) {return;}
date_str = $.trim(date_str);
date_str = date_str.replace(/\.\d\d\d+/,""); // remove the milliseconds
date_str = date_str.replace(/-/,"/").replace(/-/,"/"); //substitute - with /
date_str = date_str.replace(/T/," ").replace(/Z/," UTC"); //remove T and substitute Z with UTC
date_str = date_str.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // +08:00 -> +0800
var parsed_date = new Date(date_str);
var relative_to = (arguments.length > 1) ? arguments[1] : new Date(); //defines relative to what ..default is now
var delta = parseInt((relative_to.getTime()-parsed_date)/1000);
delta=(delta<2)?2:delta;
var r = '';
if (delta < 60) {
r = delta + ' seconds ago';
} else if(delta < 120) {
r = 'a minute ago';
} else if(delta < (45*60)) {
r = (parseInt(delta / 60, 10)).toString() + ' minutes ago';
} else if(delta < (2*60*60)) {
r = 'an hour ago';
} else if(delta < (24*60*60)) {
r = '' + (parseInt(delta / 3600, 10)).toString() + ' hours ago';
} else if(delta < (48*60*60)) {
r = 'a day ago';
} else {
r = (parseInt(delta / 86400, 10)).toString() + ' days ago';
}
return 'about ' + r;
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:47:17+00:00Added an answer on May 28, 2026 at 1:47 am

    The problem appears to be you are using the function before you define it. This is why you are receiving the undefined error. Try changing the order so that the function is evaluated last.

    dayOfWeek = function (d) {
                var dayNames = new Array('SUN','MON','TUE','WED','THU','FRI','SAT');
                var day = toTimestamp(d);
                //alert(day);
                return dayNames[day.getDay()];
            }
    toTimestamp = function (strDate){
                return new Date(Date.parse(strDate));
            }
    dayOfWeek('Sun Jan 08 2012 02:00:00 GMT+0200 (FLE Standard Time)');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
I am trying to display this output, as a date: 1296524384 But when I
Im trying to display hyperlinks (formated as hyperlink) in a listview row but not
I'm trying to display an array of files in order of date (last modified).
I'm trying to display the page owner and last modified date on the footer
I've been trying to display text using a Quartz context, but no matter what
I'm trying to make work this example from http://developer.android.com/resources/tutorials/views/hello-timepicker.html , no errors while compiling
Currently I am trying to get the date (Month and Year specifically) and display
I'm trying to display a DATE field fetched from a DB2 instance. In Oracle
Hey i'm trying to display a date/time from a timestamp field using: echo $date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.