[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I have a datetime string.  How do I format it for output?

Posted on 2011-10-14
3
Medium Priority
?
123 Views
Last Modified: 2012-05-12
Hey guys.  I thought this should be an easy one but its turning out not to be.  

This is my issue in its most basic form:  I want to write raw HTML so that when I open that HTML my predefined datetime is output based on a format I also have defined.

So for example, lets say my datetime string is 2011-08-13 10:15:39.000.

When I load my page into IE, I want the page to show 10:15.

Thats it.  I was expecting to find something like what we have for numbers.  I was expecting this would/should work:  <format:"hh:mm">2011-08-13 10:15:39.000</format> but obviously it doesn't.

So how do I do it?  Thanks!
0
Comment
Question by:JasonWilliam
  • 2
3 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36971528
HTML will not modify any data you give it.  You can use HTML to change the appearance but not the content.  If you can use javascript, you can use it to extract a 'substring' from the date string.  http://www.w3schools.com/jsref/jsref_substring.asp
0
 

Author Comment

by:JasonWilliam
ID: 36971594
Ok I understand.

Let me ask this then:  If I'm relegated to using Javascript to get this done, is there a more efficient way of formatting my datestring?  Seems like javascript would have to have some datetime format function that will accept my datestime string?

The end game here is to support a variable datetime format.  My user is going to give me a format string, and I'm going to output the datetime (from another source) in the fomat they've specified.

0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 750 total points
ID: 36971622
The javascript Date functions are mostly about getting a date from the local system and displaying it.  http://www.w3schools.com/jsref/jsref_obj_date.asp
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question