I'm trying to display the current date and time on my iPad.

First, I'm not sure this is a valid post to this forum.  If not, I'd appreciate knowg in where I can get help. 
I have tried several ways to display the current date and time on my iPad.  None  work.  Most things I try give me complier errors but the latest code compiles but won't display the correct time. 
Here's the dispatch code in my ViewController.m file:
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
    dispatch_async(queue, ^{
        [NSTimer scheduledTimerWithTimeInterval:NSTimeInterval)1.0f target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES];
Here's the updateLabel code: (which never gets executed).
- (void)updateLabel:(id) sender {
    dispatch_sync(dispatch_get_main_queue(), ^{
    NSLog(@"Datefield Update Called");
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"EEEE, MMMM dd, yyyy 'at' HH:mm  ZZZZ"];
    NSDate *dayTime = [NSDate date];
    NSString *formattedDateString = [dateFormatter stringFromDate:dayTime];
        _dateField.text = formattedDateString;
    [self.view addSubview:_dateField];
    NSLog(@"Datefield %@",_dateField.text);

Your code is needlessly complicated and has a few problems:
// These objects should be created only once.
NSTimer *dateAndTimeTimer; (You might need to make this a property with a strong reference).
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"EEEE, MMMMM dd, yyyy 'at' HH:mm ZZZZ"];
// The subview should only be added once.
[self.view addSubview:_dateField];
[self performSelectorOnMainThread:@selector(startDateAndTimeTimer)
                        withObject:nil
                     waitUntilDone:YES];
-(void)startDateAndTimeTimer
    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1
                                                      target:self
                                                    selector:@selector(updateLabel)
                                                    userInfo:nil
                                                     repeats:YES];
    dateAndTimeTimer = timer;
    [[NSRunLoop mainRunLoop] addTimer:dateAndTimeTimer forMode:NSRunLoopCommonModes];
-(void)updateLabel
     NSDate *dateTime = [NSDate date];
     NSString *formattedDataString = [dateFormatter stringFromDate:dateTime];
     _dateField.text = formattedDateString;
     NSLog(@"_dateField.text=%@", _dateField.text);

Similar Messages

  • How to display the current Date and time in xslt version 1

    i am using xslt version 1 .i want to display the current date and time in the output xml using xslt(Jdeveloper) ..i just added the namespace xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
         xmlns:ns1="urn:oracle:integration:b2b:7D30046DC68A4FA689956D8241FA3B99">
    and used thsi function <xsl:value-of select = "xp20:current-date()"/>
    but it does not works for me ..help needed????
    Edited by: user9519185 on Jan 20, 2009 3:04 AM

    Use a formula: =NOW()
    Format the cell for Date and Time, with both the Date part and the Time part displayed. Format the two parts as you wish, using the choices in the Inspector's menus.
    The cell will update each time the table is recalculated.
    (Description is for Numbers '09 (Mac), Numbers for iOS will be similar, but not necessarly identical in details.)
    Regards,
    Barry

  • Sample XSLT code to Display the Current date and time

    Hi all,
    Please Let me know code to display the system date in my target in xslt mapping.
    I am trying fn:current-datetime() function for the same.but could not get how to use it .Is it  function right  function.If so please send me the examples on the same.
    Thanks and Regards,
    Srini

    hey
    use this date:date-time()
    also have a look at this
    http://www.w3.org/TR/xpath-functions/#func-current-dateTime
    thanx
    ahmad

  • Put the current date and time in a string

    I am having trouble trying to put the current date and time from my Calendar object into a string
    any ideas?

    Calendar timeCal = Calendar.getInstance();
    timeCal.setTime(new Date(System.currentTimeMillis() - startTime ));
    String date = formatToTwoDigits(timeCal.get(Calendar.HOUR_OF_DAY))     + ":" +
    formatToTwoDigits(timeCal.get(Calendar.MINUTE))          + ":" +
    formatToTwoDigits(timeCal.get(Calendar.SECOND));
    private String formatToTwoDigits(int i) {
    String ret = null;
    i = i % 100;
    if (i < 10) {
    ret = "0" + Integer.toString(i);
    } else {
    ret = Integer.toString(i);
    return ret;
    You can figure out yourselve how to display the date, use other Calendar.XXX properties.
    Good luck!

  • Wrote the current Date and Time in the backend

    HI everyone,
    I created a table view, where I display several records. Right now I will add an record to this table, which should be written back in the backend and automaticaly add the current date and time.
    But I don´t know to make this. I tried several time with the funktion  "now()", but it doesn´t work. So any help for me, to explain how I can display the actual time and then write it back to the backend?
    Thanks

    we use a crm system. but the BAPI I mentioned was
    just to play with. My basis will develop a new API
    for the project, that have the requested Inputfields.
    But what I tottaly forget was, that there has to be a
    field for the time, so thanks for the advice.
    No Problem.
    I´m still of the opinion , that it should be possible
    to add the curret time in a field with the
    funcionality of the VC, even there is a way to show a
    clock with the current time. My problem is that I
    can´t figuer out how to do this.
    Therefore you can use the TNow() function (Time functions) and the Now() Function (Date functions). You can cast them to a string and concatenate the string, then you have the date of today with the current time. This string you can format and transfer it as input for your BAPI_ADD_BP for example.
    Hope that helps.
    Best Regards,
    Marcel

  • Get the Current Date and Time of a Location

    I have created a windowsPhoneApplication in silverLight 8.1.In my application,I have to upload videos on some server.The Uploading get failed If the Date and Time settings of my device is not the current Date and Time.So How can I get the current date
    and time even if the device settings is wrong?

    Hi shifana,
    Do you know server's time zone? If yes, you can manually translate to the correct time zone.
    Otherwise try some online time acquire API.
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get the current data and time of SCOM server via SCOM SDK (API) calls?

    Hi,
    I need to read the current date and time of SCOM server via SOM SDK.
    Is there a class in SDK that provides this info ?
    Thanks,
    satheesh

    To get time and date of Alerts of SCOM, You can use following command let "get-scomalert"
    Also, You can refer below links
    http://blog.tyang.org/2013/02/21/using-scom-2012-sdk-to-retrieve-resource-pools-information/
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question, please click "Mark As Answer"
    Mai Ali | My blog: Technical

  • I Need to Write the current Date and Time

    I need to write the current date and time to calculate the spend time in each instruction.
    What is the instrucion?
    Thanks.
    MIGUEL ANGEL CARO
    [email protected]

    The current time can be determined with a Date object:
    Date now = new java.util.Date() ;or if you are interested in the seconds since the epoch:
    System.currentTimeMillis() ;If you wanted to print them out:
    System.out.println( new java.util.Date() ) ;
    System.out.println( System.currentTimeMillis() ) ;Kenny

  • How to print the current date and time?

    Hi Friends!
    I have tried this program to print the current time and date,
    #include <iostream>
    #include <time.h>
    using namespace std;
    int main()
    time_t tim;
    time(&tim);
    cout << ctime(&tim);
    return 0;
    But it show the warning as;
    warning C4996: 'ctime': This function or variable may be unsafe. Consider using ctime_s instead.
    Can anyone suggest whats wrong with this?

    i also got many warring when i use old version keyword. as i note on think thatin new vc++ has many keyword change with _s. the old keyword works even get warring.or you can change to as it suggest.For About ctime_s
    Check this link for more detail (RefLink)
    No, it shows error, when you use ctime_s instead of ctime.
    error C2660: 'ctime_s' : function does not take 1 arguments

  • Displaying Current Date and Time in JSP

    Hi,
    I need to insert the current date time in Ms SQL Server Database using jsp page. The format of the code willbe
    insert into table(update_date) values ('2007-01-01 10:02:21');
    But i am not getting how to display the current date and time ie. 2007-01-01 10:02:21 using jsp.
    I have tried using
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    GregorianCalendar cal = new GregorianCalendar();
    String dd = sdf.format(cal.getTime());
    insert into table(update_date) values (dd);
    But it didnot get inserted data.
    Can anybody figure out with simple ideas.
    Thank You

    Why then are you trying to insert the current date on a table?
    To show the current date on the JSP you might try
    <%=new Date()%>Or the way you had it on your first post with the date formatter and then use the <%=%> tags. Anyway, it seems to me I'm not really understanding what you actually want to do :-p
    P.S. NOW() is a MySQL function too, not only MSSQL server (didn't even know it had it too ;-))
    mysql> insert into a(up) values (now());
    Query OK, 1 row affected (0.00 sec)
    mysql> select * from a;
    +------------+
    | up         |
    +------------+
    | 2007-04-09 |
    +------------+Message was edited by:
    benubach
    Message was edited by:
    benubach

  • Display current date and time

    Hello everyone,
    how can I display the current date and time in a simple text field?
    Best Mobilizer

    Hello,
    You can simply use
    now()
    You can also do more complex things with this.
    Text(Now(),"hh:mm:ss a/p")
    Check the following page for all the possible functions
    http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745510
    Regards
    StonyArc

  • Is there currently a way to change this back to displaying the actually date and

    New helpdesk in version 7.4 seems to have gone back to using '1 week ago', '2 months ago' time stamps for ticket comments.
    Is there currently a way to change this back to displaying the actually date and time?
    This topic first appeared in the Spiceworks Community

    New helpdesk in version 7.4 seems to have gone back to using '1 week ago', '2 months ago' time stamps for ticket comments.
    Is there currently a way to change this back to displaying the actually date and time?
    This topic first appeared in the Spiceworks Community

  • Need to display current date and time in arabic

    Hi,
    I'm very new to arabic and probable this is sumthing simple.
    I have to work on a flash arabic application.
    Through actionscript 2 I'm getting the current date and time.
    I want to display this in arabic. Please suggest me a solution.
    Thanks
    Sunira

    You would have to work out some font or something. I have no experience with Arabic

  • Query to deduct the time from current date and time

    I want to get the query to deduct time(180 mins) from the current date and time.
    Regards
    Pavan

    SQL> select to_char(sysdate,'dd.mm.yyyy hh24:mi:ss') curr,
      2         to_char(sysdate - interval '180' minute,'dd.mm.yyyy hh24:mi:ss') past from dual
      3  /
    CURR                PAST
    24.08.2007 16:18:37 24.08.2007 13:18:37
    SQL> 

  • Insert current date and time into Oracle date type field

    I have a JDBC current date and time insert into Oracle 9i that almost works. It submits the current date and a fixed time into the Oracle date type field. I am using Tomcat 6.0.20.
    For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will insert as: 16-Feb-2010 12:00:00 AM
    The date part works but the time always shows 12:00:00 AM no matter what date or time the data is inserted.
    Here is what I have for my JDBC inserts and I also tried something with DateFormat:
    PreparedStatement ps; Date mydate = new Date(new java.util.Date().getTime()); //insert statement here.... stmt.setDate(1,mydate);
    I also tried:
    PreparedStatement ps; java.sql.Timestamp mydate = new java.sql.Timestamp(new java.util.Date().getTime()); SimpleDateFormat fmt = new SimpleDateFormat(.... //insert statement here.... ps.setTimestamp(1,fmt.format(mydate));
    Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
    Anyway to get the current date and time? For example if I insert the data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in Oracle.

    sportsMarkr wrote:
    Date mydate = new Date(new java.util.Date().getTime());Please see the javadocs for java.sql.Date and note the part that says "...to zero"
    [http://java.sun.com/javase/6/docs/api/java/sql/Date.html]
    If you want a date and time then use java.sql.Timestamp.

Maybe you are looking for

  • Locking

    i have a table that is used by different users at the same time for updation & query only. What is the best locking sequence that can i use to update the record, or how can i know that table/row is locked so that the message can be displayed on the s

  • Manual tracks progression in playlists

    Hi everybody, i'm italian so sorry for my english. The question is: I absolutely need to disable the automatical progression of the tracks in a playlist. I want that at the end of any track the playback stops, and then I want to decide when to restar

  • Cannot validate adobe premiere & photoshop elements 13

    Im having a problem with activating or ''validating'' my serial. I bought adobe premiere elements & adobe photoshop elements 13 yesterday and everytime i start either of the programs it says i have 29 days left of my test period, and then i choose ''

  • I need an Adobe Acrobat 9 Standard download link

    I'm reloading a PC, and have the licence, and I can see the  link for Acrobat 9 Pro, but not Acrobat 9 standard.

  • Can I split to multiple monitors?

    I just bought a Mac Mini and I want to split out to multiple monitors. Preferably I want to go out with a VGA and DVI or 2 VGA's if possible. Can it split to multiple monitors? I am trying using a presentation program to send the signal to multiple w