Title: Modify date object
Last modified: August 24, 2021

---

# Modify date object

 *  [usmansagri](https://wordpress.org/support/users/usmansagri/)
 * (@usmansagri)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/modify-date-object/)
 * Hi
 * i am using wordpress api to fetch blog posts from i want to know how can i modify“
   date” proper date only or how can i seperate date and time from “date”
    -  This topic was modified 4 years, 8 months ago by [Jan Dembowski](https://wordpress.org/support/users/jdembowski/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fmodify-date-object%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Sandip Mondal – a11n](https://wordpress.org/support/users/sandipmondal/)
 * (@sandipmondal)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/modify-date-object/#post-14798106)
 * Hi [@usmansagri](https://wordpress.org/support/users/usmansagri/),
 * After you fetch the data from the API and convert it into JSON format. You can
   divide the date string into two separate substrings – date and time.
 * Please refer to the JS code below:
 *     ```
       const datefromapi = data.date;
       const indexOf_T = datefromapi.indexOf("T");
       const date = datefromapi.substr(0,indexOf_T);
       const time = datefromapi.substr(indexOf_T + 1);
       ```
   
 * I hope this helps.
 *  Thread Starter [usmansagri](https://wordpress.org/support/users/usmansagri/)
 * (@usmansagri)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/modify-date-object/#post-14809088)
 * How can i achieve that in the following code? i have to fetch all the posts and
   their timestamp!
 *     ```
       return(
             <View style={styles.container}>
                {isLoading ? (<ActivityIndicator />): (
                <FlatList 
                 data={catPost}
                 keyExtractor={({ id },index) => id}
                 renderItem={({ item }) => (
                   <TouchableOpacity onPress={() =>  navigation.navigate('CatPostModal')}>
                     {item.featured_media>0?<Image style={{width:Dimensions.width,height:250}} source={{
                         uri: item.imageLink
                       }}/>:null}
                     <View style={{padding:5,backgroundColor:'#fff',margin:5}}><Text style={{fontWeight:'bold',color:'#3578e5',fontSize:20,marginTop:5}}>{item.title.rendered}</Text>
                     <Text style={{color:'#000',marginTop:5}}>{item.date}</Text>
                     </View>
                   </TouchableOpacity>
                 )
               }
               />
             )}
             </View>
           )
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Modify date object’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [usmansagri](https://wordpress.org/support/users/usmansagri/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/modify-date-object/#post-14809088)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
